[PATCH 3.12 014/142] spi: fix parent-device reference leak

From: Jiri Slaby
Date: Wed Feb 24 2016 - 06:24:42 EST


From: Johan Hovold <johan@xxxxxxxxxx>

3.12-stable review patch. If anyone has any objections, please let me know.

===============

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@xxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
drivers/spi/spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5ddda10472c6..1470ee2660c3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1104,7 +1104,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
master->bus_num = -1;
master->num_chipselect = 1;
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;
--
2.7.1