diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-18 02:53:22 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-06-24 16:48:56 -0400 |
commit | eadc49b1a8d09480f14caea292142f103a89c77a (patch) | |
tree | ed78a3cfdd22e9754eaadcd1c73c5edd2d03cf5b /drivers | |
parent | c95e62ce8905aab62fed224eaaa9b8558a0ef652 (diff) |
[SCSI] esp: Fix OOPS in esp_reset_cleanup().
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>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/esp_scsi.c | 8 | ||||
-rw-r--r-- | drivers/scsi/esp_scsi.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index a0b6d414953d..305eddef5ca1 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
@@ -2371,6 +2371,7 @@ static int esp_slave_alloc(struct scsi_device *dev) | |||
2371 | dev->hostdata = lp; | 2371 | dev->hostdata = lp; |
2372 | 2372 | ||
2373 | tp->starget = dev->sdev_target; | 2373 | tp->starget = dev->sdev_target; |
2374 | tp->starget_ref++; | ||
2374 | 2375 | ||
2375 | spi_min_period(tp->starget) = esp->min_period; | 2376 | spi_min_period(tp->starget) = esp->min_period; |
2376 | spi_max_offset(tp->starget) = 15; | 2377 | spi_max_offset(tp->starget) = 15; |
@@ -2425,10 +2426,17 @@ static int esp_slave_configure(struct scsi_device *dev) | |||
2425 | 2426 | ||
2426 | static void esp_slave_destroy(struct scsi_device *dev) | 2427 | static void esp_slave_destroy(struct scsi_device *dev) |
2427 | { | 2428 | { |
2429 | struct esp *esp = shost_priv(dev->host); | ||
2430 | struct esp_target_data *tp = &esp->target[dev->id]; | ||
2428 | struct esp_lun_data *lp = dev->hostdata; | 2431 | struct esp_lun_data *lp = dev->hostdata; |
2429 | 2432 | ||
2430 | kfree(lp); | 2433 | kfree(lp); |
2431 | dev->hostdata = NULL; | 2434 | dev->hostdata = NULL; |
2435 | |||
2436 | BUG_ON(tp->starget_ref <= 0); | ||
2437 | |||
2438 | if (!--tp->starget_ref) | ||
2439 | tp->starget = NULL; | ||
2432 | } | 2440 | } |
2433 | 2441 | ||
2434 | static int esp_eh_abort_handler(struct scsi_cmnd *cmd) | 2442 | 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 bb43a1388188..655e0b2240bf 100644 --- a/drivers/scsi/esp_scsi.h +++ b/drivers/scsi/esp_scsi.h | |||
@@ -322,6 +322,7 @@ struct esp_target_data { | |||
322 | u8 nego_goal_tags; | 322 | u8 nego_goal_tags; |
323 | 323 | ||
324 | struct scsi_target *starget; | 324 | struct scsi_target *starget; |
325 | int starget_ref; | ||
325 | }; | 326 | }; |
326 | 327 | ||
327 | struct esp_event_ent { | 328 | struct esp_event_ent { |