Skip to content

Commit

Permalink
spi: free children in spi_unregister_master, not siblings
Browse files Browse the repository at this point in the history
introduced by 49dce68 ("spi doesn't need class_device") and bad-fixed
by 350d007 ("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>
  • Loading branch information
David Lamparter authored and Grant Likely committed Sep 1, 2010
1 parent 4e4438b commit 3486008
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,9 @@ int spi_register_master(struct spi_master *master)
EXPORT_SYMBOL_GPL(spi_register_master);


static int __unregister(struct device *dev, void *master_dev)
static int __unregister(struct device *dev, void *null)
{
/* note: before about 2.6.14-rc1 this would corrupt memory: */
if (dev != master_dev)
spi_unregister_device(to_spi_device(dev));
spi_unregister_device(to_spi_device(dev));
return 0;
}

Expand All @@ -576,8 +574,7 @@ void spi_unregister_master(struct spi_master *master)
{
int dummy;

dummy = device_for_each_child(master->dev.parent, &master->dev,
__unregister);
dummy = device_for_each_child(&master->dev, NULL, __unregister);
device_unregister(&master->dev);
}
EXPORT_SYMBOL_GPL(spi_unregister_master);
Expand Down

0 comments on commit 3486008

Please sign in to comment.