lkml.org 
[lkml]   [2020]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 122/717] media: mtk-vcodec: add missing put_device() call in mtk_vcodec_init_enc_pm()
    Date
    From: Yu Kuai <yukuai3@huawei.com>

    [ Upstream commit 4affafd7bec7c65da31777f18bd20420f1aeb5f8 ]

    if of_find_device_by_node() succeed, mtk_vcodec_init_enc_pm() doesn't have
    a corresponding put_device(). Thus add jump target to fix the exception
    handling for this function implementation.

    Fixes: 4e855a6efa54 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver")
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 26 ++++++++++++++-----
    1 file changed, 19 insertions(+), 7 deletions(-)

    diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
    index ee22902aaa71c..1a047c25679fa 100644
    --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
    +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
    @@ -47,14 +47,16 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
    node = of_parse_phandle(dev->of_node, "mediatek,larb", 1);
    if (!node) {
    mtk_v4l2_err("no mediatek,larb found");
    - return -ENODEV;
    + ret = -ENODEV;
    + goto put_larbvenc;
    }

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

    pm->larbvenclt = &pdev->dev;
    @@ -67,11 +69,14 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
    enc_clk->clk_info = devm_kcalloc(&pdev->dev,
    enc_clk->clk_num, sizeof(*clk_info),
    GFP_KERNEL);
    - if (!enc_clk->clk_info)
    - return -ENOMEM;
    + if (!enc_clk->clk_info) {
    + ret = -ENOMEM;
    + goto put_larbvenclt;
    + }
    } else {
    mtk_v4l2_err("Failed to get venc clock count");
    - return -EINVAL;
    + ret = -EINVAL;
    + goto put_larbvenclt;
    }

    for (i = 0; i < enc_clk->clk_num; i++) {
    @@ -80,17 +85,24 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
    "clock-names", i, &clk_info->clk_name);
    if (ret) {
    mtk_v4l2_err("venc failed to get clk name %d", i);
    - return ret;
    + goto put_larbvenclt;
    }
    clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
    clk_info->clk_name);
    if (IS_ERR(clk_info->vcodec_clk)) {
    mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i,
    clk_info->clk_name);
    - return PTR_ERR(clk_info->vcodec_clk);
    + ret = PTR_ERR(clk_info->vcodec_clk);
    + goto put_larbvenclt;
    }
    }

    + return 0;
    +
    +put_larbvenclt:
    + put_device(pm->larbvenclt);
    +put_larbvenc:
    + put_device(pm->larbvenc);
    return ret;
    }

    --
    2.27.0


    \
     
     \ /
      Last update: 2020-12-28 15:07    [W:2.822 / U:0.264 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site