Commit dd4eddc4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Mauro Carvalho Chehab

media: mtk-mdp: Fix a refcounting bug on error in init

We need to call of_node_put(comp->dev_node); on the error paths in this
function.

Fixes: c8eb2d7e ("[media] media: Add Mediatek MDP Driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9bde425e
...@@ -57,6 +57,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, ...@@ -57,6 +57,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
{ {
struct device_node *larb_node; struct device_node *larb_node;
struct platform_device *larb_pdev; struct platform_device *larb_pdev;
int ret;
int i; int i;
comp->dev_node = of_node_get(node); comp->dev_node = of_node_get(node);
...@@ -67,8 +68,8 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, ...@@ -67,8 +68,8 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
if (IS_ERR(comp->clk[i])) { if (IS_ERR(comp->clk[i])) {
if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER) if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER)
dev_err(dev, "Failed to get clock\n"); dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(comp->clk[i]);
return PTR_ERR(comp->clk[i]); goto put_dev;
} }
/* Only RDMA needs two clocks */ /* Only RDMA needs two clocks */
...@@ -87,20 +88,27 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, ...@@ -87,20 +88,27 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
if (!larb_node) { if (!larb_node) {
dev_err(dev, dev_err(dev,
"Missing mediadek,larb phandle in %pOF node\n", node); "Missing mediadek,larb phandle in %pOF node\n", node);
return -EINVAL; ret = -EINVAL;
goto put_dev;
} }
larb_pdev = of_find_device_by_node(larb_node); larb_pdev = of_find_device_by_node(larb_node);
if (!larb_pdev) { if (!larb_pdev) {
dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); dev_warn(dev, "Waiting for larb device %pOF\n", larb_node);
of_node_put(larb_node); of_node_put(larb_node);
return -EPROBE_DEFER; ret = -EPROBE_DEFER;
goto put_dev;
} }
of_node_put(larb_node); of_node_put(larb_node);
comp->larb_dev = &larb_pdev->dev; comp->larb_dev = &larb_pdev->dev;
return 0; return 0;
put_dev:
of_node_put(comp->dev_node);
return ret;
} }
void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp) void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment