media: mediatek: vcodec: Fix potential crash in mtk_vcodec_dbgfs_remove()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 14 Jun 2023 13:07:15 +0000 (16:07 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 25 Jul 2023 07:44:26 +0000 (09:44 +0200)
commitb19c347b123cd68d6208474194947bdb6dbc1227
tree5fc71db039a01fc0a6fb9bfafc86d4d4c00ce7c7
parent5bd28eae48589694ff4e5badb03bf75dae695b3f
media: mediatek: vcodec: Fix potential crash in mtk_vcodec_dbgfs_remove()

The list iterator "dbgfs_inst" is always non-NULL.  This means that the
test for NULL inside the loop is unnecessary and it also means that the
test for NULL outside the loop will not work.  If we do not find the item
on the list with the correct the ctx_id then it will free invalid memory
leading to a crash.

Fixes: cd403a6a0419 ("media: mediatek: vcodec: Add a debugfs file to get different useful information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c