linux/drivers
Richard Röjfors df4fedeaa6 usb: g_audio: Fix crash at driver removal
If g_audio fails to open the sound control device, it crashes at removal:

Insertion:
[ 4143.836536] g_audio gadget: unable to open sound control device file: /dev/snd/controlC0
[ 4143.836543] g_audio gadget: we need at least one control device
[ 4143.836551] g_audio gadget: Linux USB Audio Gadget, version: Dec 18, 2008
[ 4143.836558] g_audio gadget: g_audio ready

Removal:
[ 4146.802643] BUG: unable to handle kernel paging request at 00023018
[ 4146.802655] IP: [<c10af9f5>] filp_close+0xa/0x5b
[ 4146.802674] *pdpt = 0000000015426001 *pde = 0000000000000000
[ 4146.802684] Oops: 0000 [#1] PREEMPT SMP
[ 4146.802692] last sysfs file: /sys/power/state
[ 4146.802701] Modules linked in: g_audio(-) ioh_udc fuse asix usbnet [last unloaded: g_audio]
[ 4146.802719]
[ 4146.802728] Pid: 1394, comm: rmmod Not tainted 2.6.33.5-26.1-ivi #1 To be filled by O.E.M./To be filled by O.E.M.
[ 4146.802738] EIP: 0060:[<c10af9f5>] EFLAGS: 00010206 CPU: 0
[ 4146.802746] EIP is at filp_close+0xa/0x5b
[ 4146.802753] EAX: 00023000 EBX: 00023000 ECX: 00000046 EDX: df842680
[ 4146.802760] ESI: e071cd4c EDI: df842680 EBP: ddbbbef0 ESP: ddbbbee4
[ 4146.802768]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 4146.802776] Process rmmod (pid: 1394, ti=ddbba000 task=dd95a4f0 task.ti=ddbba000)
[ 4146.802782] Stack:
[ 4146.802787]  d540c280 e071cd4c df2bc000 ddbbbefc e071b82c df11e440 ddbbbf04 e071c622
[ 4146.802804] <0> ddbbbf28 e071c47f 00000008 e071cd74 df11e464 df2bc01c df2bc000 e071ce68
[ 4146.802822] <0> 00000880 ddbbbf38 e07fd1b8 e071cef0 00000000 ddbbbf40 e071b9f4 ddbbbf48
[ 4146.802842] Call Trace:
[ 4146.802857]  [<e071b82c>] ? gaudio_cleanup+0x87/0xe0 [g_audio]
[ 4146.802869]  [<e071c622>] ? audio_unbind+0x8/0xc [g_audio]
[ 4146.802881]  [<e071c47f>] ? composite_unbind+0x8d/0xcb [g_audio]
[ 4146.802895]  [<e07fd1b8>] ? usb_gadget_unregister_driver+0x7b/0xc0 [ioh_udc]
[ 4146.802908]  [<e071b9f4>] ? usb_composite_unregister+0x15/0x17 [g_audio]
[ 4146.802920]  [<e071c633>] ? cleanup+0xd/0xf [g_audio]
[ 4146.802932]  [<c105a938>] ? sys_delete_module+0x185/0x1dd
[ 4146.802944]  [<c101c3ea>] ? do_page_fault+0x248/0x276
[ 4146.802956]  [<c10027d0>] ? sysenter_do_call+0x12/0x26
[ 4146.802962] Code: 12 5f 3a 00 8b 43 04 8b 40 0c 0f b3 30 3b 73 44 73 03 89 73 44 89 f8 e8 f1 61 3a 00 5b 5e 5f 5d c3 55 89 e5 57 89 d7 56 53 89 c3 <8b> 40 18 85 c0 75 0f 68 32 15 5e c1 31 f6 e8 52 39 3a 00 5a eb
[ 4146.803058] EIP: [<c10af9f5>] filp_close+0xa/0x5b SS:ESP 0068:ddbbbee4
[ 4146.803071] CR2: 0000000000023018
[ 4146.803112] ---[ end trace 0989a7e023da0434 ]---

This patch makes sure not to assign the_card if gaudio_open_snd_dev fails,
since the parent function will deallocate the card.

Also make sure all filp's in gaudio_open_snd_dev is assigned NULL upon error
and gaudio_close_snd_dev only cleanups when the filp's are non-NULL.

Signed-off-by: Richard Röjfors <richard.rojfors@pelagicore.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-12-03 12:05:35 -08:00
..
accessibility
acpi Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2010-10-26 17:28:37 -07:00
amba ARM: 6368/1: move the PrimeCell IDs to use macros 2010-10-08 10:02:27 +01:00
ata ATA: pata_octeon_cf: Use I/O clock rate for timing calculations. 2010-10-29 19:08:41 +01:00
atm drivers/atm/eni.c: Remove multiple uses of KERN_<level> 2010-10-26 11:35:37 -07:00
auxdisplay
base Merge branch 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6 2010-10-29 15:09:56 -07:00
block Merge branch 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2010-10-28 17:11:17 -07:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-10-23 11:47:02 -07:00
cdrom cdrom: gdrom: ctrl_in/outX to __raw_read/writeX conversion. 2010-10-27 14:33:39 +09:00
char audit: Call tty_audit_push_task() outside preempt disabled 2010-10-30 08:45:25 -04:00
clocksource
connector connector: remove lazy workqueue creation 2010-10-24 14:20:01 -07:00
cpufreq [CPUFREQ] add sampling_down_factor tunable to improve ondemand performance 2010-10-22 11:44:47 -04:00
cpuidle
crypto replace nested max/min macros with {max,min}3 macro 2010-10-26 16:52:12 -07:00
dca
dio
dma drivers/dma/Kconfig: add part number for Topcliff. 2010-10-29 14:14:02 -07:00
edac Merge branch 'linux_next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/i7core 2010-10-26 10:13:48 -07:00
eisa
firewire Merge branch 'ieee1394-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2010-10-25 08:05:29 -07:00
firmware dmi: log board, system, and BIOS information 2010-10-27 18:03:05 -07:00
gpio gpio: Add VIA VX855 GPIO driver 2010-10-29 00:29:51 +02:00
gpu Merge branch 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 2010-10-27 20:37:06 -07:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-10-25 07:59:01 -07:00
hwmon hwmon: (it87) Add support for the IT8721F/IT8758E 2010-10-28 20:31:51 +02:00
i2c i2c-i801: Add PCI idents for Patsburg 'IDF' SMBus controllers 2010-10-31 21:07:00 +01:00
ide ide: clean up timed out request handling 2010-10-26 10:17:30 -07:00
idle Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-idle-2.6 2010-10-26 17:28:07 -07:00
ieee802154
infiniband convert get_sb_single() users 2010-10-29 04:16:28 -04:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-10-31 21:02:39 -04:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2010-10-30 18:42:58 -07:00
leds leds: Remove auto blink in 88pm860x 2010-10-29 00:29:44 +02:00
lguest llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
macintosh Move ams driver to macintosh 2010-10-28 20:31:50 +02:00
mca
md md: tidy up device searches in read_balance. 2010-10-29 16:40:33 +11:00
media USB: fix leftover references to udev->autosuspend_delay 2010-11-17 13:24:47 -08:00
memstick block: autoconvert trivial BKL users to private mutex 2010-10-05 15:01:10 +02:00
message Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-10-22 17:34:15 -07:00
mfd mfd: Fix a memory leak when unload mc13xxx-core module 2010-10-29 00:30:43 +02:00
misc Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb 2010-10-29 11:49:38 -07:00
mmc mfd: Adding twl6030 mmc card detect support for MMC1 2010-10-29 00:29:59 +02:00
mtd Merge git://git.infradead.org/mtd-2.6 2010-10-30 08:31:35 -07:00
net USB: fix leftover references to udev->autosuspend_delay 2010-11-17 13:24:47 -08:00
nubus
of of/mips: Cleanup some include directives/files. 2010-10-21 11:10:11 -06:00
oprofile Merge branches 'perf-fixes-for-linus' and 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-10-30 11:43:26 -07:00
parisc Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6 2010-10-28 09:24:14 -07:00
parport Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-10-24 13:41:39 -07:00
pci Merge branch 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2010-10-28 17:11:17 -07:00
pcmcia Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-10-24 13:41:39 -07:00
platform Remove duplicate includes from many files 2010-10-27 18:03:18 -07:00
pnp Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2010-10-26 17:28:37 -07:00
power power: Revert "power_supply: Mark twl4030_charger as broken" 2010-10-29 00:30:44 +02:00
pps
ps3
rapidio rapidio: fix destructive port EM initialization for Tsi568 2010-10-27 18:03:16 -07:00
regulator regulator: max8998 BUCK1/2 voltage change with use of GPIOs 2010-10-29 00:30:15 +02:00
rtc rtc: Add support for the rtc found in the MC13892 PMIC 2010-10-29 00:30:01 +02:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2010-10-31 20:43:12 -04:00
sbus Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6 2010-10-25 08:19:14 -07:00
scsi [SCSI] pmcraid: add support for set timestamp command and other fixes 2010-10-29 12:03:01 -05:00
serial Merge branch 'for-linus' of git://www.jni.nu/cris 2010-11-01 07:53:19 -04:00
sfi
sh sh: intc: switch irq_desc iteration to new active IRQ iterator. 2010-10-28 11:36:31 +09:00
sn
spi Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6 2010-11-01 07:50:43 -04:00
ssb
staging USB: fix leftover references to udev->autosuspend_delay 2010-11-17 13:24:47 -08:00
tc
telephony Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
thermal
uio Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-10-24 13:41:39 -07:00
usb usb: g_audio: Fix crash at driver removal 2010-12-03 12:05:35 -08:00
uwb drivers/uwb: Use printf extension %pR for struct resource 2010-11-16 13:54:18 -08:00
vhost Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2010-10-23 11:47:02 -07:00
video Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm 2010-10-30 08:26:25 -07:00
virtio
vlynq MIPS: Add missing #inclusions of <linux/irq.h> 2010-10-07 14:08:54 +01:00
w1 w1: don't allow arbitrary users to remove w1 devices 2010-10-27 18:03:17 -07:00
watchdog WATCHDOG: octeon-wdt: Use I/O clock rate for timing calculations. 2010-10-29 19:08:42 +01:00
xen convert get_sb_single() users 2010-10-29 04:16:28 -04:00
zorro zorro: Fix device_register() error handling 2010-10-22 09:43:25 +02:00
Kconfig
Makefile Merge branch 'ieee1394-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2010-10-25 08:05:29 -07:00