media: ti: cal: fix possible memory leak in cal_ctx_create()
authorGaosheng Cui <cuigaosheng1@huawei.com>
Tue, 29 Nov 2022 11:01:59 +0000 (12:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:40 +0000 (09:33 +0100)
commit8a316112fd97690e5138212da8d4101958b27e4f
tree1934a9ac5da5d7080f65707ecdcf908e55a046b8
parentdc5887dcc5382a3b7a7806fc35b7809da013f6df
media: ti: cal: fix possible memory leak in cal_ctx_create()

[ Upstream commit 7acd650a0484d92985a0d6d867d980c6dd019885 ]

The memory of ctx is allocated in cal_ctx_create(), but it will
not be freed when cal_ctx_v4l2_init() fails, so add kfree() when
cal_ctx_v4l2_init() fails to fix it.

Fixes: d68a94e98a89 ("media: ti-vpe: cal: Split video device initialization and registration")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/ti/cal/cal.c