Commit 34860089c9e8abcc77428d29743b37ff756197e7

Authored by David Lamparter
Committed by Grant Likely
1 parent 4e4438b865

spi: free children in spi_unregister_master, not siblings

introduced by 49dce689 ("spi doesn't need class_device") and bad-fixed
by 350d0076 ("spi: fix double-free on spi_unregister_master"),
spi_unregister_master would previously device_unregister all of the spi
master's siblings (instead of its children). hilarity ensues.

fix it to unregister children.

Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

Showing 1 changed file with 3 additions and 6 deletions Side-by-side Diff

... ... @@ -554,11 +554,9 @@
554 554 EXPORT_SYMBOL_GPL(spi_register_master);
555 555  
556 556  
557   -static int __unregister(struct device *dev, void *master_dev)
  557 +static int __unregister(struct device *dev, void *null)
558 558 {
559   - /* note: before about 2.6.14-rc1 this would corrupt memory: */
560   - if (dev != master_dev)
561   - spi_unregister_device(to_spi_device(dev));
  559 + spi_unregister_device(to_spi_device(dev));
562 560 return 0;
563 561 }
564 562  
... ... @@ -576,8 +574,7 @@
576 574 {
577 575 int dummy;
578 576  
579   - dummy = device_for_each_child(master->dev.parent, &master->dev,
580   - __unregister);
  577 + dummy = device_for_each_child(&master->dev, NULL, __unregister);
581 578 device_unregister(&master->dev);
582 579 }
583 580 EXPORT_SYMBOL_GPL(spi_unregister_master);