]> git.hungrycats.org Git - linux/commitdiff
spi: fix parent-device reference leak
authorJohan Hovold <johan@kernel.org>
Mon, 14 Dec 2015 15:16:19 +0000 (16:16 +0100)
committerZefan Li <lizefan@huawei.com>
Wed, 26 Oct 2016 15:15:38 +0000 (23:15 +0800)
commit 157f38f993919b648187ba341bfb05d0e91ad2f6 upstream.

Fix parent-device reference leak due to SPI-core taking an unnecessary
reference to the parent when allocating the master structure, a
reference that was never released.

Note that driver core takes its own reference to the parent when the
master device is registered.

Fixes: 49dce689ad4e ("spi doesn't need class_device")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
drivers/spi/spi.c

index a3f31e9ab2142a2a28153ede6e404315b123d890..516fd23ba0d521cc5e3405b5d0ea8d688379039d 100644 (file)
@@ -846,7 +846,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
 
        device_initialize(&master->dev);
        master->dev.class = &spi_master_class;
-       master->dev.parent = get_device(dev);
+       master->dev.parent = dev;
        spi_master_set_devdata(master, &master[1]);
 
        return master;