summaryrefslogtreecommitdiff
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-01-30 19:47:05 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-05 15:40:28 +0300
commit9846c67974d6af64f665707bb4f68ae458684faa (patch)
treef153312f662b2cfedc6f43a2356243d2d28b54a4 /drivers/spi/spi.c
parentc52829f60f5f6e228a70162717df199e874898a8 (diff)
downloadlinux-9846c67974d6af64f665707bb4f68ae458684faa.tar.xz
spi: fix device-node leaks
commit 8324147f38019865b29d03baf28412d2ec0bd828 upstream. Make sure to release the device-node reference taken in of_register_spi_device() on errors and when deregistering the device. Fixes: 284b01897340 ("spi: Add OF binding support for SPI busses") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ddc39b4fe3d8..6db80635ace8 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -621,8 +621,10 @@ void spi_unregister_device(struct spi_device *spi)
if (!spi)
return;
- if (spi->dev.of_node)
+ if (spi->dev.of_node) {
of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
+ of_node_put(spi->dev.of_node);
+ }
if (ACPI_COMPANION(&spi->dev))
acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
device_unregister(&spi->dev);
@@ -1589,11 +1591,13 @@ of_register_spi_device(struct spi_master *master, struct device_node *nc)
if (rc) {
dev_err(&master->dev, "spi_device register error %s\n",
nc->full_name);
- goto err_out;
+ goto err_of_node_put;
}
return spi;
+err_of_node_put:
+ of_node_put(nc);
err_out:
spi_dev_put(spi);
return ERR_PTR(rc);