[PATCH] fsi: master-gpio: Fix of_node reference leak in fsi_master_gpio_probe()

Wentao Liang posted 1 patch 1 week, 1 day ago
drivers/fsi/fsi-master-gpio.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] fsi: master-gpio: Fix of_node reference leak in fsi_master_gpio_probe()
Posted by Wentao Liang 1 week, 1 day ago
In fsi_master_gpio_probe(), a reference to the device tree node is
taken with of_node_get() and stored in master.dev.of_node.  If one of
the GPIO requests or the device_create_file() call fails, the error
path frees the master without putting that reference, leaking it.

Put the device node reference before freeing the master on the error
path.  of_node_put() tolerates a NULL node, so paths with no device
tree node are unaffected.

Fixes: f6a2f8eb73f0 ("fsi: Match fsi slaves and engines to available dt nodes")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/fsi/fsi-master-gpio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 0884e143b30e..03c46f9d6543 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -861,6 +861,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
 	}
 	return 0;
  err_free:
+	of_node_put(dev_of_node(master->master.dev));
 	kfree(master);
 	return rc;
 }
-- 
2.34.1