Skip to content

Commit d683477

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: "A couple of major (hang and deadlock) fixes with fortunately fairly rare triggering conditions. The PM oops is only really triggered by people using enclosure services (rare) and the fnic driver is mostly used in enterprise environments" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: SCSI: Fix NULL pointer dereference in runtime PM fnic: Use the local variable instead of I/O flag to acquire io_req_lock in fnic_queuecommand() to avoid deadloack
2 parents eb63b34 + 49718f0 commit d683477

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

drivers/scsi/fnic/fnic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define DRV_NAME "fnic"
4141
#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42-
#define DRV_VERSION "1.6.0.17"
42+
#define DRV_VERSION "1.6.0.17a"
4343
#define PFX DRV_NAME ": "
4444
#define DFX DRV_NAME "%d: "
4545

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
425425
unsigned long ptr;
426426
struct fc_rport_priv *rdata;
427427
spinlock_t *io_lock = NULL;
428+
int io_lock_acquired = 0;
428429

429430
if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
430431
return SCSI_MLQUEUE_HOST_BUSY;
@@ -518,6 +519,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
518519
spin_lock_irqsave(io_lock, flags);
519520

520521
/* initialize rest of io_req */
522+
io_lock_acquired = 1;
521523
io_req->port_id = rport->port_id;
522524
io_req->start_time = jiffies;
523525
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
@@ -571,7 +573,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
571573
(((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc)));
572574

573575
/* if only we issued IO, will we have the io lock */
574-
if (CMD_FLAGS(sc) & FNIC_IO_INITIALIZED)
576+
if (io_lock_acquired)
575577
spin_unlock_irqrestore(io_lock, flags);
576578

577579
atomic_dec(&fnic->in_flight);

drivers/scsi/scsi_pm.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ static int sdev_runtime_suspend(struct device *dev)
217217
{
218218
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
219219
struct scsi_device *sdev = to_scsi_device(dev);
220-
int err;
220+
int err = 0;
221221

222-
err = blk_pre_runtime_suspend(sdev->request_queue);
223-
if (err)
224-
return err;
225-
if (pm && pm->runtime_suspend)
222+
if (pm && pm->runtime_suspend) {
223+
err = blk_pre_runtime_suspend(sdev->request_queue);
224+
if (err)
225+
return err;
226226
err = pm->runtime_suspend(dev);
227-
blk_post_runtime_suspend(sdev->request_queue, err);
228-
227+
blk_post_runtime_suspend(sdev->request_queue, err);
228+
}
229229
return err;
230230
}
231231

@@ -248,11 +248,11 @@ static int sdev_runtime_resume(struct device *dev)
248248
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
249249
int err = 0;
250250

251-
blk_pre_runtime_resume(sdev->request_queue);
252-
if (pm && pm->runtime_resume)
251+
if (pm && pm->runtime_resume) {
252+
blk_pre_runtime_resume(sdev->request_queue);
253253
err = pm->runtime_resume(dev);
254-
blk_post_runtime_resume(sdev->request_queue, err);
255-
254+
blk_post_runtime_resume(sdev->request_queue, err);
255+
}
256256
return err;
257257
}
258258

0 commit comments

Comments
 (0)