summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-04-06 21:22:43 -0500
committerMike Isely <isely@pobox.com>2008-04-06 21:22:43 -0500
commitdf054b4ba9e38717e792e7aa0cfc2be8a68b5529 (patch)
treebeaa99349f1126d7e47e0aafb96d0ecc78a3605b /linux/drivers/media
parent0e6c910e99357afdff08cee78c58b2ae5b49e990 (diff)
downloadmediapointer-dvb-s2-df054b4ba9e38717e792e7aa0cfc2be8a68b5529.tar.gz
mediapointer-dvb-s2-df054b4ba9e38717e792e7aa0cfc2be8a68b5529.tar.bz2
pvrusb2: Close connect/disconnect race
From: Mike Isely <isely@pobox.com> If a disconnect happens before initialization is completed, the pvrusb2 driver can accidentally touch dangling pointers. The whole initialization function must be protected by the big_lock, and once inside that lock, the initialization function should abort if it is discovered that a disconnect has already taken place. Signed-off-by: Mike Isely <isely@pobox.com>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 8efa7add9..c7263e906 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1865,10 +1865,19 @@ int pvr2_hdw_initialize(struct pvr2_hdw *hdw,
void *callback_data)
{
LOCK_TAKE(hdw->big_lock); do {
+ if (hdw->flag_disconnected) {
+ /* Handle a race here: If we're already
+ disconnected by this point, then give up. If we
+ get past this then we'll remain connected for
+ the duration of initialization since the entire
+ initialization sequence is now protected by the
+ big_lock. */
+ break;
+ }
hdw->state_data = callback_data;
hdw->state_func = callback_func;
+ pvr2_hdw_setup(hdw);
} while (0); LOCK_GIVE(hdw->big_lock);
- pvr2_hdw_setup(hdw);
return hdw->flag_init_ok;
}