aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2007-11-14 19:59:22 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-14 21:45:39 -0500
commit350d0076c5763ca2b88ca05e3889bfa7c1905f21 (patch)
tree94221d457f4f7424e9ff10789f9289181ecc5066 /drivers/spi
parentcbff2fbf55c21f50298b1aef1263b11bf510e35f (diff)
spi: fix double-free on spi_unregister_master
After 49dce689ad4ef0fd1f970ef762168e4bd46f69a3, 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>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 89769ce16f88..b31f4431849b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -457,10 +457,11 @@ done:
457EXPORT_SYMBOL_GPL(spi_register_master); 457EXPORT_SYMBOL_GPL(spi_register_master);
458 458
459 459
460static int __unregister(struct device *dev, void *unused) 460static int __unregister(struct device *dev, void *master_dev)
461{ 461{
462 /* note: before about 2.6.14-rc1 this would corrupt memory: */ 462 /* note: before about 2.6.14-rc1 this would corrupt memory: */
463 spi_unregister_device(to_spi_device(dev)); 463 if (dev != master_dev)
464 spi_unregister_device(to_spi_device(dev));
464 return 0; 465 return 0;
465} 466}
466 467
@@ -478,7 +479,8 @@ void spi_unregister_master(struct spi_master *master)
478{ 479{
479 int dummy; 480 int dummy;
480 481
481 dummy = device_for_each_child(master->dev.parent, NULL, __unregister); 482 dummy = device_for_each_child(master->dev.parent, &master->dev,
483 __unregister);
482 device_unregister(&master->dev); 484 device_unregister(&master->dev);
483} 485}
484EXPORT_SYMBOL_GPL(spi_unregister_master); 486EXPORT_SYMBOL_GPL(spi_unregister_master);