Skip to content

Commit

Permalink
media: mtk-vcodec: Release device nodes in mtk_vcodec_init_enc_pm()
Browse files Browse the repository at this point in the history
of_parse_phandle() returns the device node with refcount incremented.
There are two nodes that are used temporary in mtk_vcodec_init_enc_pm(),
but their refcounts are not decremented.

The patch adds one of_node_put() and fixes returning error codes.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
khoroshilov authored and mchehab committed Nov 23, 2018
1 parent 5628102 commit 8ea0f2b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,27 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
if (!node) {
mtk_v4l2_err("no mediatek,larb found");
return -1;
return -ENODEV;
}
pdev = of_find_device_by_node(node);
of_node_put(node);
if (!pdev) {
mtk_v4l2_err("no mediatek,larb device found");
return -1;
return -ENODEV;
}
pm->larbvenc = &pdev->dev;

node = of_parse_phandle(dev->of_node, "mediatek,larb", 1);
if (!node) {
mtk_v4l2_err("no mediatek,larb found");
return -1;
return -ENODEV;
}

pdev = of_find_device_by_node(node);
of_node_put(node);
if (!pdev) {
mtk_v4l2_err("no mediatek,larb device found");
return -1;
return -ENODEV;
}

pm->larbvenclt = &pdev->dev;
Expand Down

0 comments on commit 8ea0f2b

Please sign in to comment.