From: Lv Yunlong Date: Sun, 9 May 2021 08:24:02 +0000 (+0200) Subject: media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7dd0c9e547b6924e18712b6b51aa3cba1896ee2c;p=linux.git media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c index 684574f58e82d..90eec79ee995a 100644 --- a/drivers/media/v4l2-core/v4l2-fh.c +++ b/drivers/media/v4l2-core/v4l2-fh.c @@ -96,6 +96,7 @@ int v4l2_fh_release(struct file *filp) v4l2_fh_del(fh); v4l2_fh_exit(fh); kfree(fh); + filp->private_data = NULL; } return 0; }