forked from mirrors/linux
		
	spi: fix double-free on spi_unregister_master
After 49dce689ad, device_for_each_child
iteration hits the master device itself.  Do not call spi_unregister_device()
for the master device.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: David Brownell <david-b@pacbell.net>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
			
			
This commit is contained in:
		
							parent
							
								
									cbff2fbf55
								
							
						
					
					
						commit
						350d0076c5
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		|  | @ -457,9 +457,10 @@ int spi_register_master(struct spi_master *master) | |||
| EXPORT_SYMBOL_GPL(spi_register_master); | ||||
| 
 | ||||
| 
 | ||||
| static int __unregister(struct device *dev, void *unused) | ||||
| static int __unregister(struct device *dev, void *master_dev) | ||||
| { | ||||
| 	/* note: before about 2.6.14-rc1 this would corrupt memory: */ | ||||
| 	if (dev != master_dev) | ||||
| 		spi_unregister_device(to_spi_device(dev)); | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -478,7 +479,8 @@ void spi_unregister_master(struct spi_master *master) | |||
| { | ||||
| 	int dummy; | ||||
| 
 | ||||
| 	dummy = device_for_each_child(master->dev.parent, NULL, __unregister); | ||||
| 	dummy = device_for_each_child(master->dev.parent, &master->dev, | ||||
| 					__unregister); | ||||
| 	device_unregister(&master->dev); | ||||
| } | ||||
| EXPORT_SYMBOL_GPL(spi_unregister_master); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Atsushi Nemoto
						Atsushi Nemoto