Skip to contentSkip to conversation

Fixup LLDDs to check for valid hostdata pointer

PATCH In review Hannes Reinecke 2 participants 2 messages May 23, 2007

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

PATCH 5/9 Fixup LLDDs to check for valid hostdata pointer

slave_destory() is now called asynchronously, hence we have to check if the ->hostdata pointer is valid before accessing it. Fixup all LLDDs to verify the hostdata pointer.

---
 drivers/message/fusion/mptscsih.c   |    2 ++
 drivers/s390/scsi/zfcp_scsi.c       |    3 ---
 drivers/scsi/53c700.c               |    6 ++++--
 drivers/scsi/aic7xxx_old.c          |    8 +++++---
 drivers/scsi/esp_scsi.c             |    6 ++++--
 drivers/scsi/sym53c8xx_2/sym_glue.c |    2 ++
 6 files changed, 17 insertions(+), 10 deletions(-)
drivers/message/fusion/mptscsih.c +2 -0
index fa0f776..2907489 100644
@@ -2314,6 +2314,8 @@ mptscsih_slave_destroy(struct scsi_devic
 	starget = scsi_target(sdev);
 	vtarget = starget->hostdata;
 	vdevice = sdev->hostdata;
+	if (!vdevice)
+		return;
 
 	mptscsih_search_running_cmds(hd, vdevice);
 	vtarget->num_luns--;
drivers/s390/scsi/zfcp_scsi.c +0 -3
index 16e2d64..bae2093 100644
@@ -189,9 +189,6 @@ static void zfcp_scsi_slave_destroy(stru
 		unit->device = NULL;
 		zfcp_erp_unit_failed(unit);
 		zfcp_unit_put(unit);
-	} else {
-		ZFCP_LOG_NORMAL("bug: no unit associated with SCSI device at "
-				"address %p\n", sdpnt);
 	}
 }
 
drivers/scsi/53c700.c +4 -2
index cb02656..50a5d92 100644
@@ -2103,8 +2103,10 @@ NCR_700_slave_configure(struct scsi_devi
 STATIC void
 NCR_700_slave_destroy(struct scsi_device *SDp)
 {
-	kfree(SDp->hostdata);
-	SDp->hostdata = NULL;
+	if (SDp->hostdata) {
+		kfree(SDp->hostdata);
+		SDp->hostdata = NULL;
+	}
 }
 
 static int
drivers/scsi/aic7xxx_old.c +5 -3
index a988d5a..fcc0dfa 100644
@@ -6733,9 +6733,11 @@ aic7xxx_slave_destroy(struct scsi_device
 {
   struct aic_dev_data *aic_dev = SDptr->hostdata;
 
-  list_del(&aic_dev->list);
-  SDptr->hostdata = NULL;
-  kfree(aic_dev);
+  if (aic_dev) {
+    list_del(&aic_dev->list);
+    SDptr->hostdata = NULL;
+    kfree(aic_dev);
+  }
   return;
 }
 
drivers/scsi/esp_scsi.c +4 -2
index ec71061..b32595f 100644
@@ -2416,8 +2416,10 @@ static void esp_slave_destroy(struct scs
 {
 	struct esp_lun_data *lp = dev->hostdata;
 
-	kfree(lp);
-	dev->hostdata = NULL;
+	if (dev->hostdata) {
+		kfree(lp);
+		dev->hostdata = NULL;
+	}
 }
 
 static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
drivers/scsi/sym53c8xx_2/sym_glue.c +2 -0
index 4d78c7e..bba2df1 100644
@@ -983,6 +983,8 @@ static void sym53c8xx_slave_destroy(stru
 	struct sym_hcb *np = sym_get_hcb(sdev->host);
 	struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun);
 
+	if (!lp)
+		return;
 	if (lp->itlq_tbl)
 		sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL");
 	kfree(lp->cb_tags);
Signature · 1 line
1.4.3.4
#1 lore raw
Quoted 4 lines · Hannes Reinecke

slave_destory() is now called asynchronously, hence we have to check if the ->hostdata pointer is valid before accessing it. Fixup all LLDDs to verify the hostdata pointer.

No way we're going to put this in. This just creates a complete mess in the drivers. Please rework your patch series to avoid this issue.