alistair23-linux/drivers
Fernando Luis Vázquez Cao 47587fc098 HID: hidraw: fix warning destroying hidraw device files after parent
I noticed that after hot unplugging a Logitech unifying receiver
(drivers/hid/hid-logitech-dj.c) the kernel would occasionally spew a
stack trace similar to this:

usb 1-1.1.2: USB disconnect, device number 7
WARNING: CPU: 0 PID: 2865 at fs/sysfs/group.c:216 device_del+0x40/0x1b0()
sysfs group ffffffff8187fa20 not found for kobject 'hidraw0'
[...]
CPU: 0 PID: 2865 Comm: upowerd Tainted: G        W 3.14.0-rc4 #7
Hardware name: LENOVO 7783PN4/        , BIOS 9HKT43AUS 07/11/2011
 0000000000000009 ffffffff814cd684 ffff880427ccfdf8 ffffffff810616e7
 ffff88041ec61800 ffff880427ccfe48 ffff88041e444d80 ffff880426fab8e8
 ffff880429359960 ffffffff8106174c ffffffff81714b98 0000000000000028
Call Trace:
 [<ffffffff814cd684>] ? dump_stack+0x41/0x51
 [<ffffffff810616e7>] ? warn_slowpath_common+0x77/0x90
 [<ffffffff8106174c>] ? warn_slowpath_fmt+0x4c/0x50
 [<ffffffff81374fd0>] ? device_del+0x40/0x1b0
 [<ffffffff8137516f>] ? device_unregister+0x2f/0x50
 [<ffffffff813751fa>] ? device_destroy+0x3a/0x40
 [<ffffffffa03ca245>] ? drop_ref+0x55/0x120 [hid]
 [<ffffffffa03ca3e6>] ? hidraw_release+0x96/0xb0 [hid]
 [<ffffffff811929da>] ? __fput+0xca/0x210
 [<ffffffff8107fe17>] ? task_work_run+0x97/0xd0
 [<ffffffff810139a9>] ? do_notify_resume+0x69/0xa0
 [<ffffffff814dbd22>] ? int_signal+0x12/0x17
---[ end trace 63f4a46f6566d737 ]---

During device removal hid_disconnect() is called via hid_hw_stop() to
stop the device and free all its resources, including the sysfs
files. The problem is that if a user space process, such as upowerd,
holds a reference to a hidraw file the corresponding sysfs files will
be kept around (drop_ref() does not call device_destroy() if the open
counter is not 0) and it will be usb_disconnect() who, by calling
device_del() for the USB device, will indirectly remove the sysfs
files of the hidraw device (sysfs_remove_dir() is recursive these
days). Because of this, by the time user space releases the last
reference to the hidraw file and drop_ref() tries to destroy the
device the sysfs files are already gone and the kernel will print
the warning above.

Fix this by calling device_destroy() at USB disconnect time.

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Cc: stable@vger.kernel.org	# 3.13
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-26 11:01:28 +01:00
..
accessibility
acpi PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
amba
ata PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
atm
auxdisplay
base Revert "kernfs, sysfs, driver-core: implement kernfs_remove_self() and its wrappers" 2014-01-13 14:05:13 -08:00
bcma
block Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k 2014-01-20 09:24:31 -08:00
bluetooth
bus
cdrom
char PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
clk Merge branch 'for-next' into for-linus 2014-01-20 10:20:14 +01:00
clocksource Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-01-20 11:34:26 -08:00
connector
cpufreq intel_pstate: Add X86_FEATURE_APERFMPERF to cpu match parameters. 2014-01-06 22:16:14 +01:00
cpuidle ARM/cpuidle: remove __init tag from Calxeda cpuidle probe function 2013-12-30 11:55:20 +01:00
crypto crypto: ixp4xx - Fix kernel compile error 2014-01-01 14:06:23 +08:00
dca
devfreq
dio
dma Merge branch 'for-next' into for-linus 2014-01-20 10:20:14 +01:00
edac Merge branch 'x86-ras-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-01-20 12:10:27 -08:00
eisa Revert "EISA: Initialize device before its resources" 2014-01-17 14:57:29 -07:00
extcon extcon: gpio: Add power resume support 2014-01-09 09:53:30 +09:00
firewire firewire: sbp2: bring back WRITE SAME support 2013-12-15 16:32:32 +01:00
firmware drivers/firmware/memmap.c: use memblock apis for early memory allocations 2014-01-21 16:19:47 -08:00
fmc
gpio MFD changes due for the v3.14 merge window 2014-01-21 10:58:17 -08:00
gpu PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
hid HID: hidraw: fix warning destroying hidraw device files after parent 2014-02-26 11:01:28 +01:00
hsi
hv drivers: hv: Mark the function hv_synic_free_cpu() as static in hv.c 2013-12-18 16:41:52 -08:00
hwmon hwmon: (k10temp) Add support for Kaveri CPUs 2014-01-14 21:36:54 -08:00
hwspinlock
i2c i2c: s3c2410: fix quirk usage for 64-bit 2014-01-16 11:18:24 +01:00
ide
idle Merge branch 'x86/idle' into sched/core 2014-01-13 17:37:05 +01:00
iio MFD changes due for the v3.14 merge window 2014-01-21 10:58:17 -08:00
infiniband infiniband: make sure the src net is infiniband when create new link 2014-01-03 20:38:56 -05:00
input MFD changes due for the v3.14 merge window 2014-01-21 10:58:17 -08:00
iommu intel-iommu: fix off-by-one in pagetable freeing 2014-01-21 16:19:41 -08:00
ipack
irqchip Renesas ARM based SoC fixes for v3.13 2013-12-20 11:28:30 -08:00
isdn isdn: Drop big endian cpp checks from telespci and hfc_pci drivers 2014-01-06 15:50:51 -05:00
leds GPIO tree bulk changes for v3.14 2014-01-21 10:09:12 -08:00
lguest
macintosh Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k 2014-01-20 09:24:31 -08:00
mailbox
md A set of device-mapper changes for 3.14. 2014-01-22 20:17:48 -08:00
media
memory
memstick
message MPT / PCI: Use pci_stop_and_remove_bus_device_locked() 2014-01-14 12:14:25 -07:00
mfd MFD changes due for the v3.14 merge window 2014-01-21 10:58:17 -08:00
misc Driver core / sysfs patches for 3.14-rc1 2014-01-20 15:49:44 -08:00
mmc ARM: s3c24xx: explicit dependency on <plat/gpio-cfg.h> 2014-01-14 15:24:54 +01:00
mtd Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2014-01-06 12:20:45 +11:00
net Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-01-20 10:25:12 -08:00
nfc
ntb
nubus
of Merge remote-tracking branch 'grant/devicetree/merge' into dt-fixes 2013-12-30 12:09:47 -06:00
oprofile
parisc
parport TTY/Serial driver patches for 3.14-rc1 2014-01-20 16:05:23 -08:00
pci PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
pcmcia PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
phy USB patches for 3.14-rc1 2014-01-20 16:13:02 -08:00
pinctrl MFD changes due for the v3.14 merge window 2014-01-21 10:58:17 -08:00
platform PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
pnp
power max17042_battery: Add IRQF_ONESHOT flag to use default irq handler 2013-12-23 18:59:41 -08:00
powercap powercap / RAPL: add support for ValleyView Soc 2013-12-22 01:27:51 +01:00
pps
ps3
ptp
pwm pwm: Add LP3943 PWM driver 2014-01-21 08:28:00 +00:00
rapidio
regulator mfd: mc13xxx: Remove useless symbol MFD_MC13783 2014-01-21 08:28:09 +00:00
remoteproc
reset
rpmsg
rtc Merge branch 'fortglx/3.14/time' of git://git.linaro.org/people/john.stultz/linux into timers/core 2014-01-12 14:13:31 +01:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2014-01-20 09:23:31 -08:00
sbus
scsi SCSI for-linus on 20140122 2014-01-22 17:32:26 -08:00
sfi
sh
sn
spi Merge remote-tracking branches 'asoc/topic/ad1836', 'asoc/topic/ad193x', 'asoc/topic/adav80x', 'asoc/topic/adsp', 'asoc/topic/ak4641', 'asoc/topic/ak4642', 'asoc/topic/arizona', 'asoc/topic/atmel', 'asoc/topic/au1x', 'asoc/topic/axi', 'asoc/topic/bcm2835', 'asoc/topic/blackfin', 'asoc/topic/cs4271', 'asoc/topic/cs42l52', 'asoc/topic/da7210', 'asoc/topic/davinci', 'asoc/topic/ep93xx', 'asoc/topic/fsl', 'asoc/topic/fsl-mxs', 'asoc/topic/generic', 'asoc/topic/hdmi', 'asoc/topic/jack', 'asoc/topic/jz4740', 'asoc/topic/max98090', 'asoc/topic/mxs', 'asoc/topic/omap', 'asoc/topic/pxa', 'asoc/topic/rcar', 'asoc/topic/s6000', 'asoc/topic/sai', 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc/topic/spear', 'asoc/topic/ssm2518', 'asoc/topic/ssm2602', 'asoc/topic/tegra', 'asoc/topic/tlv320aic3x', 'asoc/topic/twl6040', 'asoc/topic/txx9', 'asoc/topic/uda1380', 'asoc/topic/width', 'asoc/topic/wm8510', 'asoc/topic/wm8523', 'asoc/topic/wm8580', 'asoc/topic/wm8711', 'asoc/topic/wm8728', 'asoc/topic/wm8731', 'asoc/topic/wm8741', 'asoc/topic/wm8750', 'asoc/topic/wm8753', 'asoc/topic/wm8776', 'asoc/topic/wm8804', 'asoc/topic/wm8900', 'asoc/topic/wm8901', 'asoc/topic/wm8940', 'asoc/topic/wm8962', 'asoc/topic/wm8974', 'asoc/topic/wm8985', 'asoc/topic/wm8988', 'asoc/topic/wm8990', 'asoc/topic/wm8991', 'asoc/topic/wm8994', 'asoc/topic/wm8995', 'asoc/topic/wm9081' and 'asoc/topic/x86' into asoc-next 2014-01-02 13:01:55 +00:00
ssb
staging USB patches for 3.14-rc1 2014-01-20 16:13:02 -08:00
target target: Remove extra percpu_ref_init 2013-12-19 14:49:54 -08:00
tc
thermal sched, thermal: Clean up preempt_enable_no_resched() abuse 2014-01-13 17:39:18 +01:00
tty tty/serial: at91: disable uart timer at start of shutdown 2014-01-13 15:55:59 -08:00
uio uio: fix devm_request_irq usage 2013-12-20 08:49:17 -08:00
usb USB patches for 3.14-rc1 2014-01-20 16:13:02 -08:00
uwb uwb: move mutex_lock to error case in uwbd_evt_handle_rc_bp_slot_change 2013-12-20 12:19:44 -08:00
vfio vfio-pci: Use pci "try" reset interface 2014-01-15 10:43:17 -07:00
vhost
video PCI changes for the v3.14 merge window: 2014-01-22 16:39:28 -08:00
virt
virtio
vlynq
vme vme: Convert VME core to register as a subsystem 2013-12-17 17:06:19 -08:00
w1
watchdog Watchdog: pcwd_usb: remove CONFIG_USB_DEBUG usage 2014-01-07 16:15:39 -08:00
xen Bug-fixes: 2013-12-20 09:34:54 -08:00
zorro
Kconfig
Makefile