Staging: easycap: use after free in easycap_delete()
authorDan Carpenter <error27@gmail.com>
Fri, 17 Jun 2011 10:25:09 +0000 (13:25 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 5 Jul 2011 17:22:50 +0000 (10:22 -0700)
The JOM() macro dereferences peasycap, so I moved the free down some
lines.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/easycap/easycap_main.c

index 62e07f6a026c86461c42e7ee88b803557c0d9a2c..84d4f77ef46bd0fff20c11caae6bdf1945a303ab 100644 (file)
@@ -913,8 +913,6 @@ static void easycap_delete(struct kref *pkref)
        allocation_audio_struct = peasycap->allocation_audio_struct;
        registered_audio        = peasycap->registered_audio;
 
-       kfree(peasycap);
-
        if (0 <= kd && DONGLE_MANY > kd) {
                if (mutex_lock_interruptible(&mutex_dongle)) {
                        SAY("ERROR: cannot down mutex_dongle\n");
@@ -929,6 +927,9 @@ static void easycap_delete(struct kref *pkref)
        } else {
                SAY("ERROR: cannot purge dongle[].peasycap");
        }
+
+       kfree(peasycap);
+
 /*---------------------------------------------------------------------------*/
        SAY("%8i=video urbs    after all deletions\n", allocation_video_urb);
        SAY("%8i=video pages   after all deletions\n", allocation_video_page);