Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: dee747f88167 ("media: imx: Don't register IPU subdevs/links if CSI port missing")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Joe Hattori and committed by
Hans Verkuil
094f5c31 9f2ce86a

+2 -6
+2 -6
drivers/staging/media/imx/imx-media-of.c
··· 54 54 break; 55 55 56 56 ret = imx_media_of_add_csi(imxmd, csi_np); 57 + of_node_put(csi_np); 57 58 if (ret) { 58 59 /* unavailable or already added is not an error */ 59 60 if (ret == -ENODEV || ret == -EEXIST) { 60 - of_node_put(csi_np); 61 61 continue; 62 62 } 63 63 64 64 /* other error, can't continue */ 65 - goto err_out; 65 + return ret; 66 66 } 67 67 } 68 68 69 69 return 0; 70 - 71 - err_out: 72 - of_node_put(csi_np); 73 - return ret; 74 70 } 75 71 EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs);