linux/drivers/parport
Jiri Slaby 91905b6f4a parport: parport_pc, do not remove parent devices early
When the parport_pc module is removed from the system, all parport
devices are iterated in parport_pc_exit and removed by a call to
parport_pc_unregister_port. Note that some parport devices have its
'struct device' parent, known as port->dev.  And when port->dev is a
platform device, it is destroyed in parport_pc_exit too.

Now, when parport_pc_unregister_port is called for a going port,
drv->detach(port) is called for every parport driver in the system.
ppdev can be one of them. ppdev's detach() tears down its per-port
sysfs directory, which established port->dev as a parent earlier.

But since parport_pc_exit kills port->dev parents before unregisters
ports proper, ppdev's sysfs directory has no living parent anymore.
This results in the following warning:

WARNING: CPU: 1 PID: 785 at fs/sysfs/group.c:219 sysfs_remove_group+0x9b/0xa0
sysfs group ffffffff81c69e20 not found for kobject 'parport1'
Modules linked in: parport_pc(E-) ppdev(E) [last unloaded: ppdev]
CPU: 1 PID: 785 Comm: rmmod Tainted: G        W   E  3.18.0-rc5-next-20141120+ #824
...
Call Trace:
...
 [<ffffffff810aff76>] warn_slowpath_fmt+0x46/0x50
 [<ffffffff8123d81b>] sysfs_remove_group+0x9b/0xa0
 [<ffffffff814c27e7>] dpm_sysfs_remove+0x57/0x60
 [<ffffffff814b6ac9>] device_del+0x49/0x240
 [<ffffffff814b6ce2>] device_unregister+0x22/0x70
 [<ffffffff814b6dac>] device_destroy+0x3c/0x50
 [<ffffffffc012209a>] pp_detach+0x4a/0x60 [ppdev]
 [<ffffffff814b32dd>] parport_remove_port+0x11d/0x150
 [<ffffffffc0137328>] parport_pc_unregister_port+0x28/0xf0 [parport_pc]
 [<ffffffffc0138c0e>] parport_pc_exit+0x76/0x468 [parport_pc]
 [<ffffffff81128dbc>] SyS_delete_module+0x18c/0x230

It is also easily reproducible on qemu with two dummy ports '-parallel
/dev/null -parallel /dev/null'.

So switch the order of killing the two structures. But since port is
freed by parport_pc_unregister_port, we have to remember port->dev
in a local variable.

Perhaps nothing worse than the warning happens thanks to the device
refcounting. We *should* be on the safe side.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Martin Pluskal <mpluskal@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 19:33:57 -08:00
..
BUGS-parport
daisy.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
ieee1284_ops.c parport: fix ieee1284_epp_read_addr 2008-02-08 09:22:36 -08:00
ieee1284.c Fix common misspellings 2011-03-31 11:26:23 -03:00
Kconfig parport: fix menu breakage 2014-07-25 18:00:23 -07:00
Makefile
multiface.h
parport_amiga.c parport: amiga: remove unnecessary platform_set_drvdata() 2013-08-27 21:39:16 -07:00
parport_atari.c parport: remove unused dead code from lowlevel drivers 2012-04-20 09:48:27 -07:00
parport_ax88796.c parport: convert drivers/parport/* to use module_platform_driver() 2011-11-30 20:11:46 +09:00
parport_cs.c drivers/parport: use module_pcmcia_driver() in pcmcia drivers 2013-03-15 12:26:38 -07:00
parport_gsc.c parisc: parport0: fix this legacy no-device port driver! 2013-06-01 14:46:42 +02:00
parport_gsc.h parisc: parport0: fix this legacy no-device port driver! 2013-06-01 14:46:42 +02:00
parport_ip32.c drivers/parport/parport_ip32.c: use PTR_ERR_OR_ZERO 2014-08-08 15:57:25 -07:00
parport_mfc3.c zorro: ZTWO_VADDR() should return "void __iomem *" 2013-11-26 11:09:07 +01:00
parport_pc.c parport: parport_pc, do not remove parent devices early 2014-11-26 19:33:57 -08:00
parport_serial.c parport: Add support for the WCH353 1S/1P multi-IO card 2014-05-28 12:30:48 -07:00
parport_sunbpp.c parport: use kmemdup instead of kmalloc + memcpy 2013-03-25 10:42:06 -07:00
probe.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
procfs.c parport: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:15 -07:00
share.c parport: fix interruptible_sleep_on race 2014-02-28 16:22:42 -08:00
TODO-parport