]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Sun, 9 May 2021 08:24:02 +0000 (10:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:22:32 +0000 (16:22 +0200)
[ Upstream commit 7dd0c9e547b6924e18712b6b51aa3cba1896ee2c ]

A use after free bug caused by the dangling pointer
filp->privitate_data in v4l2_fh_release.
See https://lore.kernel.org/patchwork/patch/1419058/.

My patch sets the dangling pointer to NULL to provide
robust.

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
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>
drivers/media/v4l2-core/v4l2-fh.c

index 1d076deb05a90a5f147f2ef14502653b68217bb7..ce844ecc334029d8280562bde68a47dd19c5754a 100644 (file)
@@ -107,6 +107,7 @@ int v4l2_fh_release(struct file *filp)
                v4l2_fh_del(fh);
                v4l2_fh_exit(fh);
                kfree(fh);
+               filp->private_data = NULL;
        }
        return 0;
 }