mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
media: platform: mtk-mdp3: Add missing check and free for ida_alloc
[ Upstream commitd00f592250] Add the check for the return value of the ida_alloc in order to avoid NULL pointer dereference. Moreover, free allocated "ctx->id" if mdp_m2m_open fails later in order to avoid memory leak. Fixes:61890ccaef("media: platform: mtk-mdp3: add MediaTek MDP3 driver") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c2e5548173
commit
51fc1880e4
@@ -566,7 +566,11 @@ static int mdp_m2m_open(struct file *file)
|
|||||||
goto err_free_ctx;
|
goto err_free_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->id = ida_alloc(&mdp->mdp_ida, GFP_KERNEL);
|
ret = ida_alloc(&mdp->mdp_ida, GFP_KERNEL);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_unlock_mutex;
|
||||||
|
ctx->id = ret;
|
||||||
|
|
||||||
ctx->mdp_dev = mdp;
|
ctx->mdp_dev = mdp;
|
||||||
|
|
||||||
v4l2_fh_init(&ctx->fh, vdev);
|
v4l2_fh_init(&ctx->fh, vdev);
|
||||||
@@ -617,6 +621,8 @@ err_release_handler:
|
|||||||
v4l2_fh_del(&ctx->fh);
|
v4l2_fh_del(&ctx->fh);
|
||||||
err_exit_fh:
|
err_exit_fh:
|
||||||
v4l2_fh_exit(&ctx->fh);
|
v4l2_fh_exit(&ctx->fh);
|
||||||
|
ida_free(&mdp->mdp_ida, ctx->id);
|
||||||
|
err_unlock_mutex:
|
||||||
mutex_unlock(&mdp->m2m_lock);
|
mutex_unlock(&mdp->m2m_lock);
|
||||||
err_free_ctx:
|
err_free_ctx:
|
||||||
kfree(ctx);
|
kfree(ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user