Commit bfcc593b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] scsi_unregister() oops fix

Some drivers such as aha1542 and aic7xxx_old will call scsi_register() and
then, if some succeeding operations fails they will call scsi_unregister(),
without an intervening scsi_set_host().

This causes an oops in scsi_put_device(), because kobj->parent is NULL.

In other words, scsi_register() immediately followed by scsi_unregister()
is guaranteed to oops.

The patch makes scsi_host_dev_release() more robust against this usage
pattern.
parent e56ac609
...@@ -158,7 +158,13 @@ static void scsi_host_dev_release(struct device *dev) ...@@ -158,7 +158,13 @@ static void scsi_host_dev_release(struct device *dev)
scsi_proc_hostdir_rm(shost->hostt); scsi_proc_hostdir_rm(shost->hostt);
scsi_destroy_command_freelist(shost); scsi_destroy_command_freelist(shost);
put_device(parent); /*
* Some drivers (eg aha1542) do scsi_register()/scsi_unregister()
* during probing without performing a scsi_set_device() in between.
* In this case dev->parent is NULL.
*/
if (parent)
put_device(parent);
kfree(shost); kfree(shost);
} }
......
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