Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] fix up non-modular SCSI

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>

authored by

James Bottomley and committed by
James Bottomley
f479ab87 884d25cc

+4 -2
+4 -2
drivers/scsi/scsi.c
··· 873 873 */ 874 874 void scsi_device_put(struct scsi_device *sdev) 875 875 { 876 + struct module *module = sdev->host->hostt->module; 877 + 876 878 /* The module refcount will be zero if scsi_device_get() 877 879 * was called from a module removal routine */ 878 - if (likely(module_refcount(sdev->host->hostt->module) != 0)) 879 - module_put(sdev->host->hostt->module); 880 + if (module && module_refcount(module) != 0) 881 + module_put(module); 880 882 put_device(&sdev->sdev_gendev); 881 883 } 882 884 EXPORT_SYMBOL(scsi_device_put);