summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-07-03 02:45:49 +0000
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-24 09:14:05 -0700
commit13ac0ea3cf0b540c409d5a5ff1508f2d630d475d (patch)
tree24c42ad6b2aa20a535b30046ea1e9423cdff9f66
parentb80a43a3627d4dede30e59706443dc1653f5e2de (diff)
SCSI: esp: Fix OOPS in esp_reset_cleanup().
commit eadc49b1a8d09480f14caea292142f103a89c77a upstream OOPS reported by Friedrich Oslage <bluebird@porno-bullen.de> The problem here is that tp->starget is set every time a lun is allocated for a particular target so we can catch the sdev_target parent value. The reset handler uses the NULL'ness of this value to determine which targets are active. But esp_slave_destroy() does not NULL out this value when appropriate. So for every target that doesn't respond, the SCSI bus scan causes a stale pointer to be left here, with ensuing crashes like you're seeing. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/scsi/esp_scsi.c8
-rw-r--r--drivers/scsi/esp_scsi.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index bfdee5968892..f34e410c5fea 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2364,6 +2364,7 @@ static int esp_slave_alloc(struct scsi_device *dev)
dev->hostdata = lp;
tp->starget = dev->sdev_target;
+ tp->starget_ref++;
spi_min_period(tp->starget) = esp->min_period;
spi_max_offset(tp->starget) = 15;
@@ -2412,10 +2413,17 @@ static int esp_slave_configure(struct scsi_device *dev)
static void esp_slave_destroy(struct scsi_device *dev)
{
+ struct esp *esp = shost_priv(dev->host);
+ struct esp_target_data *tp = &esp->target[dev->id];
struct esp_lun_data *lp = dev->hostdata;
kfree(lp);
dev->hostdata = NULL;
+
+ BUG_ON(tp->starget_ref <= 0);
+
+ if (!--tp->starget_ref)
+ tp->starget = NULL;
}
static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
index d5576d54ce76..b1273ea8efc4 100644
--- a/drivers/scsi/esp_scsi.h
+++ b/drivers/scsi/esp_scsi.h
@@ -322,6 +322,7 @@ struct esp_target_data {
u8 nego_goal_tags;
struct scsi_target *starget;
+ int starget_ref;
};
struct esp_event_ent {