[PATCH] gpu: ipu-v3: fix OF node reference leaks in ipu_add_client_devices()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ipu_add_client_devices() does not release the obtained OF node reference
in the error path. Call of_node_put() on the OF nodes before returning
an error.

This bug was found by an experimental static analysis tool that I am
developing.

Fixes: 17e052175039 ("gpu: ipu-v3: Do not bail out on missing optional port nodes")
Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/gpu/ipu-v3/ipu-common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 947323f4a234..8091b959b7ea 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -1178,6 +1178,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 			ret = platform_device_add(pdev);
 		if (ret) {
 			platform_device_put(pdev);
+			of_node_put(of_node);
 			goto err_register;
 		}
 	}
@@ -1185,6 +1186,8 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 	return 0;
 
 err_register:
+	while (--i >= 0)
+		of_node_put(client_reg[i].pdata.of_node);
 	platform_device_unregister_children(to_platform_device(dev));
 
 	return ret;
-- 
2.34.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux