Skip to content

Commit 094f5c3

Browse files
joehattorihverkuil
authored andcommitted
staging: media: imx: fix OF node leak in imx_media_add_of_subdevs()
imx_media_add_of_subdevs() calls of_parse_phandle() and passes the obtained node to imx_media_of_add_csi(). The passed node is used in v4l2_async_nf_add_fwnode(), which increments the refcount of the node. Therefore, while the current implementation only releases the node when imx_media_of_add_csi() fails, but should always release it. Call of_node_put() right after imx_media_of_add_csi(). Fixes: dee747f ("media: imx: Don't register IPU subdevs/links if CSI port missing") Signed-off-by: Joe Hattori <[email protected]> Reviewed-by: Vladimir Zapolskiy <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 9f2ce86 commit 094f5c3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/staging/media/imx/imx-media-of.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,18 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
5454
break;
5555

5656
ret = imx_media_of_add_csi(imxmd, csi_np);
57+
of_node_put(csi_np);
5758
if (ret) {
5859
/* unavailable or already added is not an error */
5960
if (ret == -ENODEV || ret == -EEXIST) {
60-
of_node_put(csi_np);
6161
continue;
6262
}
6363

6464
/* other error, can't continue */
65-
goto err_out;
65+
return ret;
6666
}
6767
}
6868

6969
return 0;
70-
71-
err_out:
72-
of_node_put(csi_np);
73-
return ret;
7470
}
7571
EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs);

0 commit comments

Comments
 (0)