Skip to content

Commit 7308e92

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: "Eleven small fixes, ten in drivers. Of the two fixes marked core, one is in the raid helper class (used by some raid device drivers) and the other one is the /proc/scsi/scsi parsing fix for potential reads beyond the end of the buffer" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: qedf: Fix firmware halt over suspend and resume scsi: qedi: Fix firmware halt over suspend and resume scsi: qedi: Fix potential deadlock on &qedi_percpu->p_work_lock scsi: lpfc: Remove reftag check in DIF paths scsi: ufs: renesas: Fix private allocation scsi: snic: Fix possible memory leak if device_add() fails scsi: core: Fix possible memory leak if device_add() fails scsi: core: Fix legacy /proc parsing buffer overflow scsi: 53c700: Check that command slot is not NULL scsi: fnic: Replace return codes in fnic_clean_pending_aborts() scsi: storvsc: Fix handling of virtual Fibre Channel timeouts
2 parents a785fd2 + ef222f5 commit 7308e92

File tree

11 files changed

+68
-41
lines changed

11 files changed

+68
-41
lines changed

drivers/scsi/53c700.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ NCR_700_intr(int irq, void *dev_id)
15981598
printk("scsi%d (%d:%d) PHASE MISMATCH IN SEND MESSAGE %d remain, return %p[%04x], phase %s\n", host->host_no, pun, lun, count, (void *)temp, temp - hostdata->pScript, sbcl_to_string(NCR_700_readb(host, SBCL_REG)));
15991599
#endif
16001600
resume_offset = hostdata->pScript + Ent_SendMessagePhaseMismatch;
1601-
} else if(dsp >= to32bit(&slot->pSG[0].ins) &&
1601+
} else if (slot && dsp >= to32bit(&slot->pSG[0].ins) &&
16021602
dsp <= to32bit(&slot->pSG[NCR_700_SG_SEGMENTS].ins)) {
16031603
int data_transfer = NCR_700_readl(host, DBC_REG) & 0xffffff;
16041604
int SGcount = (dsp - to32bit(&slot->pSG[0].ins))/sizeof(struct NCR_700_SG_List);

drivers/scsi/fnic/fnic.h

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

2828
#define DRV_NAME "fnic"
2929
#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
30-
#define DRV_VERSION "1.6.0.54"
30+
#define DRV_VERSION "1.6.0.55"
3131
#define PFX DRV_NAME ": "
3232
#define DFX DRV_NAME "%d: "
3333

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
21392139
bool new_sc)
21402140

21412141
{
2142-
int ret = SUCCESS;
2142+
int ret = 0;
21432143
struct fnic_pending_aborts_iter_data iter_data = {
21442144
.fnic = fnic,
21452145
.lun_dev = lr_sc->device,
@@ -2159,9 +2159,11 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
21592159

21602160
/* walk again to check, if IOs are still pending in fw */
21612161
if (fnic_is_abts_pending(fnic, lr_sc))
2162-
ret = FAILED;
2162+
ret = 1;
21632163

21642164
clean_pending_aborts_end:
2165+
FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
2166+
"%s: exit status: %d\n", __func__, ret);
21652167
return ret;
21662168
}
21672169

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
109109
}
110110
}
111111

112-
#define LPFC_INVALID_REFTAG ((u32)-1)
113-
114112
/**
115113
* lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
116114
* @phba: The Hba for which this call is being executed.
@@ -978,8 +976,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
978976

979977
sgpe = scsi_prot_sglist(sc);
980978
lba = scsi_prot_ref_tag(sc);
981-
if (lba == LPFC_INVALID_REFTAG)
982-
return 0;
983979

984980
/* First check if we need to match the LBA */
985981
if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) {
@@ -1560,8 +1556,6 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
15601556

15611557
/* extract some info from the scsi command for pde*/
15621558
reftag = scsi_prot_ref_tag(sc);
1563-
if (reftag == LPFC_INVALID_REFTAG)
1564-
goto out;
15651559

15661560
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
15671561
rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -1723,8 +1717,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
17231717
/* extract some info from the scsi command */
17241718
blksize = scsi_prot_interval(sc);
17251719
reftag = scsi_prot_ref_tag(sc);
1726-
if (reftag == LPFC_INVALID_REFTAG)
1727-
goto out;
17281720

17291721
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
17301722
rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -1953,8 +1945,6 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
19531945

19541946
/* extract some info from the scsi command for pde*/
19551947
reftag = scsi_prot_ref_tag(sc);
1956-
if (reftag == LPFC_INVALID_REFTAG)
1957-
goto out;
19581948

19591949
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
19601950
rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -2154,8 +2144,6 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
21542144
/* extract some info from the scsi command */
21552145
blksize = scsi_prot_interval(sc);
21562146
reftag = scsi_prot_ref_tag(sc);
2157-
if (reftag == LPFC_INVALID_REFTAG)
2158-
goto out;
21592147

21602148
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
21612149
rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -2746,8 +2734,6 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
27462734

27472735
src = (struct scsi_dif_tuple *)sg_virt(sgpe);
27482736
start_ref_tag = scsi_prot_ref_tag(cmd);
2749-
if (start_ref_tag == LPFC_INVALID_REFTAG)
2750-
goto out;
27512737
start_app_tag = src->app_tag;
27522738
len = sgpe->length;
27532739
while (src && protsegcnt) {
@@ -3493,11 +3479,11 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba,
34933479
scsi_cmnd->sc_data_direction);
34943480

34953481
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
3496-
"9084 Cannot setup S/G List for HBA"
3497-
"IO segs %d/%d SGL %d SCSI %d: %d %d\n",
3482+
"9084 Cannot setup S/G List for HBA "
3483+
"IO segs %d/%d SGL %d SCSI %d: %d %d %d\n",
34983484
lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
34993485
phba->cfg_total_seg_cnt, phba->cfg_sg_seg_cnt,
3500-
prot_group_type, num_sge);
3486+
prot_group_type, num_sge, ret);
35013487

35023488
lpfc_cmd->seg_cnt = 0;
35033489
lpfc_cmd->prot_seg_cnt = 0;

drivers/scsi/qedf/qedf_main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static void qedf_remove(struct pci_dev *pdev);
3131
static void qedf_shutdown(struct pci_dev *pdev);
3232
static void qedf_schedule_recovery_handler(void *dev);
3333
static void qedf_recovery_handler(struct work_struct *work);
34+
static int qedf_suspend(struct pci_dev *pdev, pm_message_t state);
3435

3536
/*
3637
* Driver module parameters.
@@ -3271,6 +3272,7 @@ static struct pci_driver qedf_pci_driver = {
32713272
.probe = qedf_probe,
32723273
.remove = qedf_remove,
32733274
.shutdown = qedf_shutdown,
3275+
.suspend = qedf_suspend,
32743276
};
32753277

32763278
static int __qedf_probe(struct pci_dev *pdev, int mode)
@@ -4000,6 +4002,22 @@ static void qedf_shutdown(struct pci_dev *pdev)
40004002
__qedf_remove(pdev, QEDF_MODE_NORMAL);
40014003
}
40024004

4005+
static int qedf_suspend(struct pci_dev *pdev, pm_message_t state)
4006+
{
4007+
struct qedf_ctx *qedf;
4008+
4009+
if (!pdev) {
4010+
QEDF_ERR(NULL, "pdev is NULL.\n");
4011+
return -ENODEV;
4012+
}
4013+
4014+
qedf = pci_get_drvdata(pdev);
4015+
4016+
QEDF_ERR(&qedf->dbg_ctx, "%s: Device does not support suspend operation\n", __func__);
4017+
4018+
return -EPERM;
4019+
}
4020+
40034021
/*
40044022
* Recovery handler code
40054023
*/

drivers/scsi/qedi/qedi_main.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static struct nvm_iscsi_block *qedi_get_nvram_block(struct qedi_ctx *qedi);
6969
static void qedi_recovery_handler(struct work_struct *work);
7070
static void qedi_schedule_hw_err_handler(void *dev,
7171
enum qed_hw_err_type err_type);
72+
static int qedi_suspend(struct pci_dev *pdev, pm_message_t state);
7273

7374
static int qedi_iscsi_event_cb(void *context, u8 fw_event_code, void *fw_handle)
7475
{
@@ -1976,8 +1977,9 @@ static int qedi_cpu_offline(unsigned int cpu)
19761977
struct qedi_percpu_s *p = this_cpu_ptr(&qedi_percpu);
19771978
struct qedi_work *work, *tmp;
19781979
struct task_struct *thread;
1980+
unsigned long flags;
19791981

1980-
spin_lock_bh(&p->p_work_lock);
1982+
spin_lock_irqsave(&p->p_work_lock, flags);
19811983
thread = p->iothread;
19821984
p->iothread = NULL;
19831985

@@ -1988,7 +1990,7 @@ static int qedi_cpu_offline(unsigned int cpu)
19881990
kfree(work);
19891991
}
19901992

1991-
spin_unlock_bh(&p->p_work_lock);
1993+
spin_unlock_irqrestore(&p->p_work_lock, flags);
19921994
if (thread)
19931995
kthread_stop(thread);
19941996
return 0;
@@ -2510,6 +2512,22 @@ static void qedi_shutdown(struct pci_dev *pdev)
25102512
__qedi_remove(pdev, QEDI_MODE_SHUTDOWN);
25112513
}
25122514

2515+
static int qedi_suspend(struct pci_dev *pdev, pm_message_t state)
2516+
{
2517+
struct qedi_ctx *qedi;
2518+
2519+
if (!pdev) {
2520+
QEDI_ERR(NULL, "pdev is NULL.\n");
2521+
return -ENODEV;
2522+
}
2523+
2524+
qedi = pci_get_drvdata(pdev);
2525+
2526+
QEDI_ERR(&qedi->dbg_ctx, "%s: Device does not support suspend operation\n", __func__);
2527+
2528+
return -EPERM;
2529+
}
2530+
25132531
static int __qedi_probe(struct pci_dev *pdev, int mode)
25142532
{
25152533
struct qedi_ctx *qedi;
@@ -2868,6 +2886,7 @@ static struct pci_driver qedi_pci_driver = {
28682886
.remove = qedi_remove,
28692887
.shutdown = qedi_shutdown,
28702888
.err_handler = &qedi_err_handler,
2889+
.suspend = qedi_suspend,
28712890
};
28722891

28732892
static int __init qedi_init(void)

drivers/scsi/raid_class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev,
248248
return 0;
249249

250250
err_out:
251+
put_device(&rc->dev);
251252
list_del(&rc->node);
252253
rd->component_count--;
253254
put_device(component_dev);

drivers/scsi/scsi_proc.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
406406
size_t length, loff_t *ppos)
407407
{
408408
int host, channel, id, lun;
409-
char *buffer, *p;
409+
char *buffer, *end, *p;
410410
int err;
411411

412412
if (!buf || length > PAGE_SIZE)
@@ -421,10 +421,14 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
421421
goto out;
422422

423423
err = -EINVAL;
424-
if (length < PAGE_SIZE)
425-
buffer[length] = '\0';
426-
else if (buffer[PAGE_SIZE-1])
427-
goto out;
424+
if (length < PAGE_SIZE) {
425+
end = buffer + length;
426+
*end = '\0';
427+
} else {
428+
end = buffer + PAGE_SIZE - 1;
429+
if (*end)
430+
goto out;
431+
}
428432

429433
/*
430434
* Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
@@ -433,10 +437,10 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
433437
if (!strncmp("scsi add-single-device", buffer, 22)) {
434438
p = buffer + 23;
435439

436-
host = simple_strtoul(p, &p, 0);
437-
channel = simple_strtoul(p + 1, &p, 0);
438-
id = simple_strtoul(p + 1, &p, 0);
439-
lun = simple_strtoul(p + 1, &p, 0);
440+
host = (p < end) ? simple_strtoul(p, &p, 0) : 0;
441+
channel = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
442+
id = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
443+
lun = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
440444

441445
err = scsi_add_single_device(host, channel, id, lun);
442446

@@ -447,10 +451,10 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
447451
} else if (!strncmp("scsi remove-single-device", buffer, 25)) {
448452
p = buffer + 26;
449453

450-
host = simple_strtoul(p, &p, 0);
451-
channel = simple_strtoul(p + 1, &p, 0);
452-
id = simple_strtoul(p + 1, &p, 0);
453-
lun = simple_strtoul(p + 1, &p, 0);
454+
host = (p < end) ? simple_strtoul(p, &p, 0) : 0;
455+
channel = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
456+
id = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
457+
lun = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0;
454458

455459
err = scsi_remove_single_device(host, channel, id, lun);
456460
}

drivers/scsi/snic/snic_disc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ snic_tgt_create(struct snic *snic, struct snic_tgt_id *tgtid)
303303
"Snic Tgt: device_add, with err = %d\n",
304304
ret);
305305

306+
put_device(&tgt->dev);
306307
put_device(&snic->shost->shost_gendev);
307308
spin_lock_irqsave(snic->shost->host_lock, flags);
308309
list_del(&tgt->list);

drivers/scsi/storvsc_drv.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
16741674
*/
16751675
static enum scsi_timeout_action storvsc_eh_timed_out(struct scsi_cmnd *scmnd)
16761676
{
1677-
#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
1678-
if (scmnd->device->host->transportt == fc_transport_template)
1679-
return fc_eh_timed_out(scmnd);
1680-
#endif
16811677
return SCSI_EH_RESET_TIMER;
16821678
}
16831679

0 commit comments

Comments
 (0)