Skip to content

Commit

Permalink
[SCSI] fix up non-modular SCSI
Browse files Browse the repository at this point in the history
The recent change to the way scsi_device_get()/put() work broke the
non modular build (we do a module_refcount on a NULL).  Fix this by
checking for non-null before checking module_refcount().

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
  • Loading branch information
James Bottomley authored and James Bottomley committed Sep 7, 2006
1 parent 884d25c commit f479ab8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,12 @@ EXPORT_SYMBOL(scsi_device_get);
*/
void scsi_device_put(struct scsi_device *sdev)
{
struct module *module = sdev->host->hostt->module;

/* The module refcount will be zero if scsi_device_get()
* was called from a module removal routine */
if (likely(module_refcount(sdev->host->hostt->module) != 0))
module_put(sdev->host->hostt->module);
if (module && module_refcount(module) != 0)
module_put(module);
put_device(&sdev->sdev_gendev);
}
EXPORT_SYMBOL(scsi_device_put);
Expand Down

0 comments on commit f479ab8

Please sign in to comment.