Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34860089 authored by David Lamparter's avatar David Lamparter Committed by Grant Likely
Browse files

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: default avatarDavid Lamparter <equinox@diac24.net>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 4e4438b8
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -554,10 +554,8 @@ done:
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));
	return 0;
}
@@ -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);