mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
staging: media: imx: fix OF node leak in imx_media_add_of_subdevs()
[ Upstream commit 094f5c315f756b19198e6c401aa821ac0e868750 ]
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: dee747f881 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8f18d9e6f6
commit
1dd01dc435
@@ -55,22 +55,18 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
|
||||
break;
|
||||
|
||||
ret = imx_media_of_add_csi(imxmd, csi_np);
|
||||
of_node_put(csi_np);
|
||||
if (ret) {
|
||||
/* unavailable or already added is not an error */
|
||||
if (ret == -ENODEV || ret == -EEXIST) {
|
||||
of_node_put(csi_np);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* other error, can't continue */
|
||||
goto err_out;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
of_node_put(csi_np);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs);
|
||||
|
||||
Reference in New Issue
Block a user