Skip to contentSkip to conversation

Unhandled error condition in aic7xxx

PATCH In review Daniel Walker 2 participants 2 messages Sep 1, 2005 – Sep 2, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Unhandled error condition in aic7xxx

This patch should handle the case when scsi_add_host() fails.

drivers/scsi/aic7xxx/aic7xxx_osm.c +11 -2
Index: linux-2.6.13/drivers/scsi/aic7xxx/aic7xxx_osm.c
===================================================================
@@ -996,6 +996,7 @@ ahc_linux_register_host(struct ahc_softc
 	struct	 Scsi_Host *host;
 	char	*new_name;
 	u_long	 s;
+	int error = 0;
 
 	template->name = ahc->description;
 	host = scsi_host_alloc(template, sizeof(struct ahc_softc *));
@@ -1029,8 +1030,16 @@ ahc_linux_register_host(struct ahc_softc
 
 	host->transportt = ahc_linux_transport_template;
 
-	scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */
-	scsi_scan_host(host);
+	error = scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
+	if (error) {
+		/* 
+		 * Discard host variable on error.
+		 */
+		scsi_host_put(host);
+		return (error);
+	} 
+ 	scsi_scan_host(host);
+	
 	return (0);
 }
 
#1 lore raw
Quoted 20 lines · On Thu, 01 Sep 2005 12:38:24 -0700 Daniel Walker wrote:

This patch should handle the case when scsi_add_host() fails.

Index: linux-2.6.13/drivers/scsi/aic7xxx/aic7xxx_osm.c
===================================================================

drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -0
@@ -996,6 +996,7 @@ ahc_linux_register_host(struct ahc_softc
 	struct	 Scsi_Host *host;
 	char	*new_name;
 	u_long	 s;
+	int error = 0;
 
 	template->name = ahc->description;
 	host = scsi_host_alloc(template, sizeof(struct ahc_softc *));
@@ -1029,8 +1030,16 @@ ahc_linux_register_host(struct ahc_softc
 
 	host->transportt = ahc_linux_transport_template;

drivers/scsi/aic7xxx/aic7xxx_osm.c ahc_linux_register_host(struct ahc_softc · line 1039

Quoted 10 lines
drivers/scsi/aic7xxx/aic7xxx_osm.c +7 -2
 
-	scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */
-	scsi_scan_host(host);
+	error = scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
+	if (error) {
+		/* 
+		 * Discard host variable on error.
+		 */
+		scsi_host_put(host);
+		return (error);

no parens on return, just: return error;

drivers/scsi/aic7xxx/aic7xxx_osm.c ahc_linux_register_host(struct ahc_softc · line 1044

Quoted 5 lines
drivers/scsi/aic7xxx/aic7xxx_osm.c +3 -0
+	} 
+ 	scsi_scan_host(host);
+	
 	return (0);
 }

---
~Randy