spi: fix device-node leaks
commit8324147f38
upstream. Make sure to release the device-node reference taken in of_register_spi_device() on errors and when deregistering the device. Fixes:284b018973
("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>
This commit is contained in:
parent
c52829f60f
commit
9846c67974
|
@ -621,8 +621,10 @@ void spi_unregister_device(struct spi_device *spi)
|
||||||
if (!spi)
|
if (!spi)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (spi->dev.of_node)
|
if (spi->dev.of_node) {
|
||||||
of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
|
of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
|
||||||
|
of_node_put(spi->dev.of_node);
|
||||||
|
}
|
||||||
if (ACPI_COMPANION(&spi->dev))
|
if (ACPI_COMPANION(&spi->dev))
|
||||||
acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
|
acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
|
||||||
device_unregister(&spi->dev);
|
device_unregister(&spi->dev);
|
||||||
|
@ -1589,11 +1591,13 @@ of_register_spi_device(struct spi_master *master, struct device_node *nc)
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(&master->dev, "spi_device register error %s\n",
|
dev_err(&master->dev, "spi_device register error %s\n",
|
||||||
nc->full_name);
|
nc->full_name);
|
||||||
goto err_out;
|
goto err_of_node_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spi;
|
return spi;
|
||||||
|
|
||||||
|
err_of_node_put:
|
||||||
|
of_node_put(nc);
|
||||||
err_out:
|
err_out:
|
||||||
spi_dev_put(spi);
|
spi_dev_put(spi);
|
||||||
return ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
|
|
Loading…
Reference in a new issue