Skip to contentSkip to conversation

fix for sd removal loop

PATCH In review sullivan 2 participants 2 messages Aug 16, 2002 SCSI

lore
Share & tools
lore

sullivan

author
#0 lore raw

PATCH 1/1 fix for sd removal loop

Attached is a trivial fix for an excessive loop that is encountered in removal of the sd module. This case is hit when sd is insmod'ed and rmmod'ed without any scsi devices being registered. In this case, within exit_sd(), sd_template.dev_max remains at zero and the N_USED_SD_MAJORS macro yields an incorrect result since it is treating dev_max as an signed number.

drivers/scsi/hosts.h +1 -1
diff -Nau --exclude='p.*' linux-2.5-devclass/drivers/scsi/hosts.h linux-2.5-devclass-mike/drivers/scsi/hosts.h
@@ -519,7 +519,7 @@
     unsigned int max_major;      /* Maximum major in range. */
     unsigned int nr_dev;	  /* Number currently attached */
     unsigned int dev_noticed;	  /* Number of devices detected. */
-    unsigned int dev_max;	  /* Current size of arrays */
+    signed int dev_max;	  /* Current size of arrays */
     unsigned blk:1;		  /* 0 if character device */
     int (*detect)(Scsi_Device *); /* Returns 1 if we can attach this device */
     int (*init)(void);		  /* Sizes arrays based upon number of devices
#1 lore raw

Mike S,

While this fix solves the problem it looks odd to have a signed value for an array size.

What about checking "sd_registered" just after
scsi_unregister_device in exit_sd.

-Mike A

Quoted 20 lines · sullivan [[email protected]] wrote:

Attached is a trivial fix for an excessive loop that is encountered in removal of the sd module. This case is hit when sd is insmod'ed and rmmod'ed without any scsi devices being registered. In this case, within exit_sd(), sd_template.dev_max remains at zero and the N_USED_SD_MAJORS macro yields an incorrect result since it is treating dev_max as an signed number.

diff -Nau --exclude='p.*' linux-2.5-devclass/drivers/scsi/hosts.h linux-2.5-devclass-mike/drivers/scsi/hosts.h

drivers/scsi/hosts.h +1 -1
@@ -519,7 +519,7 @@
     unsigned int max_major;      /* Maximum major in range. */
     unsigned int nr_dev;	  /* Number currently attached */
     unsigned int dev_noticed;	  /* Number of devices detected. */
-    unsigned int dev_max;	  /* Current size of arrays */
+    signed int dev_max;	  /* Current size of arrays */
     unsigned blk:1;		  /* 0 if character device */
     int (*detect)(Scsi_Device *); /* Returns 1 if we can attach this device */
     int (*init)(void);		  /* Sizes arrays based upon number of devices
Signature · 2 lines
Michael Anderson
[email protected]