mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -mm] scsi ips gcc 4.1 warning fix
@ 2006-05-10  2:55 Daniel Walker
  0 siblings, 0 replies; only message in thread
From: Daniel Walker @ 2006-05-10  2:55 UTC (permalink / raw)
  To: akpm; +Cc: ipslinux, linux-kernel

If the ips_phase1_init fails someplace , and ips_hotplug is enabled, index
would get used to access and array. This looks like definite badness.

Fixes the following warning,

drivers/scsi/ips.c: In function 'ips_register_scsi':
drivers/scsi/ips.c:7043: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result
drivers/scsi/ips.c: In function 'ips_insert_device':
drivers/scsi/ips.c:7124: warning: 'index' may be used uninitialized in this function

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

Index: linux-2.6.16/drivers/scsi/ips.c
===================================================================
--- linux-2.6.16.orig/drivers/scsi/ips.c
+++ linux-2.6.16/drivers/scsi/ips.c
@@ -7121,7 +7121,7 @@ module_exit(ips_module_exit);
 static int __devinit
 ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
 {
-	int index;
+	int index = 0;
 	int rc;
 
 	METHOD_TRACE("ips_insert_device", 1);
@@ -7129,17 +7129,17 @@ ips_insert_device(struct pci_dev *pci_de
 		return -1;
 
 	rc = ips_init_phase1(pci_dev, &index);
-	if (rc == SUCCESS)
+	if (rc == SUCCESS) {
 		rc = ips_init_phase2(index);
 
-	if (ips_hotplug)
-		if (ips_register_scsi(index)) {
-			ips_free(ips_ha[index]);
-			rc = -1;
-		}
+		if (ips_hotplug)
+			if (ips_register_scsi(index)) {
+				ips_free(ips_ha[index]);
+				rc = -1;
+			}
 
-	if (rc == SUCCESS)
 		ips_num_controllers++;
+	}
 
 	ips_next_controller = ips_num_controllers;
 	return rc;
Index: linux-2.6.16/drivers/scsi/ips.h
===================================================================
--- linux-2.6.16.orig/drivers/scsi/ips.h
+++ linux-2.6.16/drivers/scsi/ips.h
@@ -109,7 +109,8 @@
    #else
       #define IPS_REGISTER_HOSTS(SHT)      (!ips_detect(SHT))
       #define IPS_UNREGISTER_HOSTS(SHT)
-      #define IPS_ADD_HOST(shost,device)   do { scsi_add_host(shost,device); scsi_scan_host(shost); } while (0)
+      #define IPS_ADD_HOST(shost,device)   do { if (scsi_add_host(shost,device)) return -ENODEV; \
+							scsi_scan_host(shost); } while (0)
       #define IPS_REMOVE_HOST(shost)       scsi_remove_host(shost)
       #define IPS_SCSI_SET_DEVICE(sh,ha)   do { } while (0)
       #define IPS_PRINTK(level, pcidev, format, arg...)                 \

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-10  2:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10  2:55 [PATCH -mm] scsi ips gcc 4.1 warning fix Daniel Walker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®