media: platform: mtk-mdp3: Add missing check and free for ida_alloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 9 Feb 2023 13:52:45 +0000 (14:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:10 +0000 (23:03 +0900)
commit51fc1880e47421ee7b192372e8e86b7bbba40776
tree8f224cc16dd32067dc2018c61ef09f2928449ab2
parentc2e55481731b0e8c96f30f661e430aa884fbd354
media: platform: mtk-mdp3: Add missing check and free for ida_alloc

[ Upstream commit d00f592250782538cda87745607695b0fe27dcd4 ]

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: 61890ccaefaf ("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>
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c