ALSA: rawmidi: fix oops (use after free) when unloading a driver module
authorClemens Ladisch <clemens@ladisch.de>
Fri, 15 Oct 2010 10:06:18 +0000 (12:06 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 29 Oct 2010 04:43:53 +0000 (21:43 -0700)
commit28b4c9130be4377517c171f34cb9f0ba9f213f23
tree9e9589ae2d657b56c7d01de1bbecded9d5f6e6a5
parent08f00ae28f93b85bd7dccdd3ace606939a970833
ALSA: rawmidi: fix oops (use after free) when unloading a driver module

commit aa73aec6c385e2c797ac25cc7ccf0318031de7c8 upstream.

When a driver module is unloaded and the last still open file is a raw
MIDI device, the card and its devices will be actually freed in the
snd_card_file_remove() call when that file is closed.  Afterwards, rmidi
and rmidi->card point into freed memory, so the module pointer is likely
to be garbage.
(This was introduced by commit 9a1b64caac82aa02cb74587ffc798e6f42c6170a.)

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reported-by: Krzysztof Foltman <wdev@foltman.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
sound/core/rawmidi.c