ide: fix hwif->gendev refcounting

class->dev_release is called by device_release() iff dev->release
is not present so ide_port_class_release() is never called and the
last hwif->gendev reference is not dropped.

Fix it by removing ide_port_class_release() and get_device() call
from ide_register_port() (device_create_drvdata() takes a hwif->gendev
reference anyway).

This patch fixes hang on wait_for_completion(&hwif->gendev_rel_comp)
in ide_unregister() reported by Pavel Machek.

Cc: Pavel Machek <pavel@suse.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent b8a0b6cc
...@@ -646,8 +646,6 @@ static int ide_register_port(ide_hwif_t *hwif) ...@@ -646,8 +646,6 @@ static int ide_register_port(ide_hwif_t *hwif)
goto out; goto out;
} }
get_device(&hwif->gendev);
hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev,
MKDEV(0, 0), hwif, hwif->name); MKDEV(0, 0), hwif, hwif->name);
if (IS_ERR(hwif->portdev)) { if (IS_ERR(hwif->portdev)) {
......
...@@ -1094,13 +1094,6 @@ struct bus_type ide_bus_type = { ...@@ -1094,13 +1094,6 @@ struct bus_type ide_bus_type = {
EXPORT_SYMBOL_GPL(ide_bus_type); EXPORT_SYMBOL_GPL(ide_bus_type);
static void ide_port_class_release(struct device *portdev)
{
ide_hwif_t *hwif = dev_get_drvdata(portdev);
put_device(&hwif->gendev);
}
int ide_vlb_clk; int ide_vlb_clk;
EXPORT_SYMBOL_GPL(ide_vlb_clk); EXPORT_SYMBOL_GPL(ide_vlb_clk);
...@@ -1305,7 +1298,6 @@ static int __init ide_init(void) ...@@ -1305,7 +1298,6 @@ static int __init ide_init(void)
ret = PTR_ERR(ide_port_class); ret = PTR_ERR(ide_port_class);
goto out_port_class; goto out_port_class;
} }
ide_port_class->dev_release = ide_port_class_release;
init_ide_data(); init_ide_data();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment