Message ID | 20241215032222.2507759-1-joe@pf.is.s.u-tokyo.ac.jp (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | gpu: ipu-v3: fix OF node reference leaks in ipu_add_client_devices() | expand |
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;
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@pf.is.s.u-tokyo.ac.jp> --- drivers/gpu/ipu-v3/ipu-common.c | 3 +++ 1 file changed, 3 insertions(+)