]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - sound/core/rawmidi.c
ALSA: rawmidi: fix oops (use after free) when unloading a driver module
[net-next-2.6.git] / sound / core / rawmidi.c
index a7868ad4d530fd40b3a9bd608bd7860a7d35ce44..cbbed0db9e560315ae0559c7e5e97786387a5371 100644 (file)
@@ -535,13 +535,15 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file)
 {
        struct snd_rawmidi_file *rfile;
        struct snd_rawmidi *rmidi;
+       struct module *module;
 
        rfile = file->private_data;
        rmidi = rfile->rmidi;
        rawmidi_release_priv(rfile);
        kfree(rfile);
+       module = rmidi->card->module;
        snd_card_file_remove(rmidi->card, file);
-       module_put(rmidi->card->module);
+       module_put(module);
        return 0;
 }