aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo B. Marliere <[email protected]>2023-10-13 01:09:12 +0200
committerGreg Kroah-Hartman <[email protected]>2024-01-25 15:35:32 -0800
commit2cf0005d315549b8d2b940ff96a66c2a889aa795 (patch)
treee1ff356d14529908f64e3a53fa2aa42f3de8a0e5
parentc56a4ad4068d7f2065595640f016ec3be88886e8 (diff)
downloadlinux-2cf0005d315549b8d2b940ff96a66c2a889aa795.tar.gz
media: pvrusb2: fix use after free on context disconnection
[ Upstream commit ded85b0c0edd8f45fec88783d7555a5b982449c1 ] Upon module load, a kthread is created targeting the pvr2_context_thread_func function, which may call pvr2_context_destroy and thus call kfree() on the context object. However, that might happen before the usb hub_event handler is able to notify the driver. This patch adds a sanity check before the invalid read reported by syzbot, within the context disconnection call stack. Reported-and-tested-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Fixes: e5be15c63804 ("V4L/DVB (7711): pvrusb2: Fix race on module unload") Signed-off-by: Ricardo B. Marliere <[email protected]> Acked-by: Mike Isely <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-context.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 14170a5d72b350..1764674de98bc0 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -268,7 +268,8 @@ void pvr2_context_disconnect(struct pvr2_context *mp)
{
pvr2_hdw_disconnect(mp->hdw);
mp->disconnect_flag = !0;
- pvr2_context_notify(mp);
+ if (!pvr2_context_shutok())
+ pvr2_context_notify(mp);
}