Skip to content

Commit 0e6582a

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Small fixes, two in drivers and the remaining a sign conversion probem in sd with no user visible consequences (non-zero is error)" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: target: tcm_loop: Fix NULL ptr dereference scsi: isci: Fix use-after-free in device removal path scsi: sd: Fix return code handling in sd_spinup_disk()
2 parents 59825bc + b71cb08 commit 0e6582a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/scsi/isci/host.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,9 @@ void isci_host_deinit(struct isci_host *ihost)
12521252

12531253
wait_for_stop(ihost);
12541254

1255+
/* No further IRQ-driven scheduling can happen past wait_for_stop(). */
1256+
tasklet_kill(&ihost->completion_tasklet);
1257+
12551258
/* phy stop is after controller stop to allow port and device to
12561259
* go idle before shutting down the phys, but the expectation is
12571260
* that i/o has been shut off well before we reach this

drivers/scsi/sd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,8 +2476,7 @@ sd_spinup_disk(struct scsi_disk *sdkp)
24762476
{
24772477
static const u8 cmd[10] = { TEST_UNIT_READY };
24782478
unsigned long spintime_expire = 0;
2479-
int spintime, sense_valid = 0;
2480-
unsigned int the_result;
2479+
int the_result, spintime, sense_valid = 0;
24812480
struct scsi_sense_hdr sshdr;
24822481
struct scsi_failure failure_defs[] = {
24832482
/* Do not retry Medium Not Present */

drivers/target/loopback/tcm_loop.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static int tcm_loop_driver_probe(struct device *dev)
393393
if (error) {
394394
pr_err("%s: scsi_add_host failed\n", __func__);
395395
scsi_host_put(sh);
396+
tl_hba->sh = NULL;
396397
return -ENODEV;
397398
}
398399
return 0;
@@ -406,8 +407,10 @@ static void tcm_loop_driver_remove(struct device *dev)
406407
tl_hba = to_tcm_loop_hba(dev);
407408
sh = tl_hba->sh;
408409

409-
scsi_remove_host(sh);
410-
scsi_host_put(sh);
410+
if (sh) {
411+
scsi_remove_host(sh);
412+
scsi_host_put(sh);
413+
}
411414
}
412415

413416
static void tcm_loop_release_adapter(struct device *dev)
@@ -436,6 +439,11 @@ static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host
436439
return -ENODEV;
437440
}
438441

442+
if (!tl_hba->sh) {
443+
device_unregister(&tl_hba->dev);
444+
return -ENODEV;
445+
}
446+
439447
return 0;
440448
}
441449

0 commit comments

Comments
 (0)