Skip to content

Commit 8addf0c

Browse files
committed
Merge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is a set of 13 fixes, a MAINTAINERS update and a sparse update. The fixes are mostly correct value initialisations, avoiding NULL derefs and some uninitialised pointer avoidance. All the patches have been incubated in -next for a few days. The final patch (use the scsi data buffer length to extract transfer size) has been rebased to add a cc to stable, but only the commit message has changed" * tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: [SCSI] use the scsi data buffer length to extract transfer size virtio-scsi: fix various bad behavior on aborted requests virtio-scsi: avoid cancelling uninitialized work items ibmvscsi: Add memory barriers for send / receive ibmvscsi: Abort init sequence during error recovery qla2xxx: Fix sparse warning in qla_target.c. bnx2fc: Improve stats update mechanism bnx2fc: do not scan uninitialized lists in case of error. fc: ensure scan_work isn't active when freeing fc_rport pm8001: Fix potential null pointer dereference and memory leak. MAINTAINERS: Update LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI) maintainers Email IDs be2iscsi: remove potential junk pointer free be2iscsi: add an missing goto in error path scsi_error: set DID_TIME_OUT correctly scsi_error: fix invalid setting of host byte
2 parents 110e430 + 77ae174 commit 8addf0c

File tree

13 files changed

+86
-43
lines changed

13 files changed

+86
-43
lines changed

MAINTAINERS

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5530,10 +5530,11 @@ S: Maintained
55305530
F: arch/arm/mach-lpc32xx/
55315531

55325532
LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
5533-
M: Nagalakshmi Nandigama <[email protected]>
5534-
M: Sreekanth Reddy <[email protected]>
5535-
5536-
5533+
M: Nagalakshmi Nandigama <[email protected]>
5534+
M: Praveen Krishnamoorthy <[email protected]>
5535+
M: Sreekanth Reddy <[email protected]>
5536+
M: Abhijit Mahajan <[email protected]>
5537+
55375538
55385539
W: http://www.lsilogic.com/support
55395540
S: Supported

drivers/scsi/be2iscsi/be_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,8 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
41984198
kfree(phba->ep_array);
41994199
phba->ep_array = NULL;
42004200
ret = -ENOMEM;
4201+
4202+
goto free_memory;
42014203
}
42024204

42034205
for (i = 0; i < phba->params.cxns_per_ctrl; i++) {

drivers/scsi/be2iscsi/be_mgmt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,8 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
10081008
BE2_IPV6 : BE2_IPV4 ;
10091009

10101010
rc = mgmt_get_if_info(phba, ip_type, &if_info);
1011-
if (rc) {
1012-
kfree(if_info);
1011+
if (rc)
10131012
return rc;
1014-
}
10151013

10161014
if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
10171015
if (if_info->dhcp_state) {

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -516,23 +516,17 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
516516
skb_pull(skb, sizeof(struct fcoe_hdr));
517517
fr_len = skb->len - sizeof(struct fcoe_crc_eof);
518518

519-
stats = per_cpu_ptr(lport->stats, get_cpu());
520-
stats->RxFrames++;
521-
stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
522-
523519
fp = (struct fc_frame *)skb;
524520
fc_frame_init(fp);
525521
fr_dev(fp) = lport;
526522
fr_sof(fp) = hp->fcoe_sof;
527523
if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) {
528-
put_cpu();
529524
kfree_skb(skb);
530525
return;
531526
}
532527
fr_eof(fp) = crc_eof.fcoe_eof;
533528
fr_crc(fp) = crc_eof.fcoe_crc32;
534529
if (pskb_trim(skb, fr_len)) {
535-
put_cpu();
536530
kfree_skb(skb);
537531
return;
538532
}
@@ -544,15 +538,13 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
544538
port = lport_priv(vn_port);
545539
if (!ether_addr_equal(port->data_src_addr, dest_mac)) {
546540
BNX2FC_HBA_DBG(lport, "fpma mismatch\n");
547-
put_cpu();
548541
kfree_skb(skb);
549542
return;
550543
}
551544
}
552545
if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA &&
553546
fh->fh_type == FC_TYPE_FCP) {
554547
/* Drop FCP data. We dont this in L2 path */
555-
put_cpu();
556548
kfree_skb(skb);
557549
return;
558550
}
@@ -562,7 +554,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
562554
case ELS_LOGO:
563555
if (ntoh24(fh->fh_s_id) == FC_FID_FLOGI) {
564556
/* drop non-FIP LOGO */
565-
put_cpu();
566557
kfree_skb(skb);
567558
return;
568559
}
@@ -572,22 +563,23 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
572563

573564
if (fh->fh_r_ctl == FC_RCTL_BA_ABTS) {
574565
/* Drop incoming ABTS */
575-
put_cpu();
576566
kfree_skb(skb);
577567
return;
578568
}
579569

570+
stats = per_cpu_ptr(lport->stats, smp_processor_id());
571+
stats->RxFrames++;
572+
stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
573+
580574
if (le32_to_cpu(fr_crc(fp)) !=
581575
~crc32(~0, skb->data, fr_len)) {
582576
if (stats->InvalidCRCCount < 5)
583577
printk(KERN_WARNING PFX "dropping frame with "
584578
"CRC error\n");
585579
stats->InvalidCRCCount++;
586-
put_cpu();
587580
kfree_skb(skb);
588581
return;
589582
}
590-
put_cpu();
591583
fc_exch_recv(lport, fp);
592584
}
593585

drivers/scsi/bnx2fc/bnx2fc_io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
282282
arr_sz, GFP_KERNEL);
283283
if (!cmgr->free_list_lock) {
284284
printk(KERN_ERR PFX "failed to alloc free_list_lock\n");
285+
kfree(cmgr->free_list);
286+
cmgr->free_list = NULL;
285287
goto mem_err;
286288
}
287289

drivers/scsi/ibmvscsi/ibmvscsi.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ static struct viosrp_crq *crq_queue_next_crq(struct crq_queue *queue)
185185
if (crq->valid & 0x80) {
186186
if (++queue->cur == queue->size)
187187
queue->cur = 0;
188+
189+
/* Ensure the read of the valid bit occurs before reading any
190+
* other bits of the CRQ entry
191+
*/
192+
rmb();
188193
} else
189194
crq = NULL;
190195
spin_unlock_irqrestore(&queue->lock, flags);
@@ -203,6 +208,11 @@ static int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata,
203208
{
204209
struct vio_dev *vdev = to_vio_dev(hostdata->dev);
205210

211+
/*
212+
* Ensure the command buffer is flushed to memory before handing it
213+
* over to the VIOS to prevent it from fetching any stale data.
214+
*/
215+
mb();
206216
return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, word1, word2);
207217
}
208218

@@ -797,7 +807,8 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
797807
evt->hostdata->dev);
798808
if (evt->cmnd_done)
799809
evt->cmnd_done(evt->cmnd);
800-
} else if (evt->done)
810+
} else if (evt->done && evt->crq.format != VIOSRP_MAD_FORMAT &&
811+
evt->iu.srp.login_req.opcode != SRP_LOGIN_REQ)
801812
evt->done(evt);
802813
free_event_struct(&evt->hostdata->pool, evt);
803814
spin_lock_irqsave(hostdata->host->host_lock, flags);

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
677677
* pm8001_get_phy_settings_info : Read phy setting values.
678678
* @pm8001_ha : our hba.
679679
*/
680-
void pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
680+
static int pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
681681
{
682682

683683
#ifdef PM8001_READ_VPD
@@ -691,11 +691,15 @@ void pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
691691
payload.offset = 0;
692692
payload.length = 4096;
693693
payload.func_specific = kzalloc(4096, GFP_KERNEL);
694+
if (!payload.func_specific)
695+
return -ENOMEM;
694696
/* Read phy setting values from flash */
695697
PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
696698
wait_for_completion(&completion);
697699
pm8001_set_phy_profile(pm8001_ha, sizeof(u8), payload.func_specific);
700+
kfree(payload.func_specific);
698701
#endif
702+
return 0;
699703
}
700704

701705
#ifdef PM8001_USE_MSIX
@@ -879,8 +883,11 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
879883
pm8001_init_sas_add(pm8001_ha);
880884
/* phy setting support for motherboard controller */
881885
if (pdev->subsystem_vendor != PCI_VENDOR_ID_ADAPTEC2 &&
882-
pdev->subsystem_vendor != 0)
883-
pm8001_get_phy_settings_info(pm8001_ha);
886+
pdev->subsystem_vendor != 0) {
887+
rc = pm8001_get_phy_settings_info(pm8001_ha);
888+
if (rc)
889+
goto err_out_shost;
890+
}
884891
pm8001_post_sas_ha_init(shost, chip);
885892
rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
886893
if (rc)

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha,
11281128
ctio->u.status1.flags =
11291129
__constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
11301130
CTIO7_FLAGS_TERMINATE);
1131-
ctio->u.status1.ox_id = entry->fcp_hdr_le.ox_id;
1131+
ctio->u.status1.ox_id = cpu_to_le16(entry->fcp_hdr_le.ox_id);
11321132

11331133
qla2x00_start_iocbs(vha, vha->req);
11341134

@@ -1262,6 +1262,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha,
12621262
{
12631263
struct atio_from_isp *atio = &mcmd->orig_iocb.atio;
12641264
struct ctio7_to_24xx *ctio;
1265+
uint16_t temp;
12651266

12661267
ql_dbg(ql_dbg_tgt, ha, 0xe008,
12671268
"Sending task mgmt CTIO7 (ha=%p, atio=%p, resp_code=%x\n",
@@ -1292,7 +1293,8 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha,
12921293
ctio->u.status1.flags = (atio->u.isp24.attr << 9) |
12931294
__constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
12941295
CTIO7_FLAGS_SEND_STATUS);
1295-
ctio->u.status1.ox_id = swab16(atio->u.isp24.fcp_hdr.ox_id);
1296+
temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
1297+
ctio->u.status1.ox_id = cpu_to_le16(temp);
12961298
ctio->u.status1.scsi_status =
12971299
__constant_cpu_to_le16(SS_RESPONSE_INFO_LEN_VALID);
12981300
ctio->u.status1.response_len = __constant_cpu_to_le16(8);
@@ -1513,6 +1515,7 @@ static int qlt_24xx_build_ctio_pkt(struct qla_tgt_prm *prm,
15131515
struct ctio7_to_24xx *pkt;
15141516
struct qla_hw_data *ha = vha->hw;
15151517
struct atio_from_isp *atio = &prm->cmd->atio;
1518+
uint16_t temp;
15161519

15171520
pkt = (struct ctio7_to_24xx *)vha->req->ring_ptr;
15181521
prm->pkt = pkt;
@@ -1541,13 +1544,13 @@ static int qlt_24xx_build_ctio_pkt(struct qla_tgt_prm *prm,
15411544
pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
15421545
pkt->exchange_addr = atio->u.isp24.exchange_addr;
15431546
pkt->u.status0.flags |= (atio->u.isp24.attr << 9);
1544-
pkt->u.status0.ox_id = swab16(atio->u.isp24.fcp_hdr.ox_id);
1547+
temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
1548+
pkt->u.status0.ox_id = cpu_to_le16(temp);
15451549
pkt->u.status0.relative_offset = cpu_to_le32(prm->cmd->offset);
15461550

15471551
ql_dbg(ql_dbg_tgt, vha, 0xe00c,
15481552
"qla_target(%d): handle(cmd) -> %08x, timeout %d, ox_id %#x\n",
1549-
vha->vp_idx, pkt->handle, QLA_TGT_TIMEOUT,
1550-
le16_to_cpu(pkt->u.status0.ox_id));
1553+
vha->vp_idx, pkt->handle, QLA_TGT_TIMEOUT, temp);
15511554
return 0;
15521555
}
15531556

@@ -2619,6 +2622,7 @@ static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
26192622
struct qla_hw_data *ha = vha->hw;
26202623
request_t *pkt;
26212624
int ret = 0;
2625+
uint16_t temp;
26222626

26232627
ql_dbg(ql_dbg_tgt, vha, 0xe01c, "Sending TERM EXCH CTIO (ha=%p)\n", ha);
26242628

@@ -2655,7 +2659,8 @@ static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
26552659
ctio24->u.status1.flags = (atio->u.isp24.attr << 9) |
26562660
__constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
26572661
CTIO7_FLAGS_TERMINATE);
2658-
ctio24->u.status1.ox_id = swab16(atio->u.isp24.fcp_hdr.ox_id);
2662+
temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
2663+
ctio24->u.status1.ox_id = cpu_to_le16(temp);
26592664

26602665
/* Most likely, it isn't needed */
26612666
ctio24->u.status1.residual = get_unaligned((uint32_t *)

drivers/scsi/qla2xxx/qla_target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ struct ctio7_to_24xx {
443443
uint16_t reserved1;
444444
__le16 flags;
445445
uint32_t residual;
446-
uint16_t ox_id;
446+
__le16 ox_id;
447447
uint16_t scsi_status;
448448
uint32_t relative_offset;
449449
uint32_t reserved2;
@@ -458,7 +458,7 @@ struct ctio7_to_24xx {
458458
uint16_t sense_length;
459459
uint16_t flags;
460460
uint32_t residual;
461-
uint16_t ox_id;
461+
__le16 ox_id;
462462
uint16_t scsi_status;
463463
uint16_t response_len;
464464
uint16_t reserved;

drivers/scsi/scsi_error.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ scmd_eh_abort_handler(struct work_struct *work)
131131
"aborting command %p\n", scmd));
132132
rtn = scsi_try_to_abort_cmd(sdev->host->hostt, scmd);
133133
if (rtn == SUCCESS) {
134-
scmd->result |= DID_TIME_OUT << 16;
134+
set_host_byte(scmd, DID_TIME_OUT);
135135
if (scsi_host_eh_past_deadline(sdev->host)) {
136136
SCSI_LOG_ERROR_RECOVERY(3,
137137
scmd_printk(KERN_INFO, scmd,
@@ -167,7 +167,7 @@ scmd_eh_abort_handler(struct work_struct *work)
167167
scmd_printk(KERN_WARNING, scmd,
168168
"scmd %p terminate "
169169
"aborted command\n", scmd));
170-
scmd->result |= DID_TIME_OUT << 16;
170+
set_host_byte(scmd, DID_TIME_OUT);
171171
scsi_finish_command(scmd);
172172
}
173173
}
@@ -287,15 +287,15 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
287287
else if (host->hostt->eh_timed_out)
288288
rtn = host->hostt->eh_timed_out(scmd);
289289

290-
if (rtn == BLK_EH_NOT_HANDLED && !host->hostt->no_async_abort)
291-
if (scsi_abort_command(scmd) == SUCCESS)
290+
if (rtn == BLK_EH_NOT_HANDLED) {
291+
if (!host->hostt->no_async_abort &&
292+
scsi_abort_command(scmd) == SUCCESS)
292293
return BLK_EH_NOT_HANDLED;
293294

294-
scmd->result |= DID_TIME_OUT << 16;
295-
296-
if (unlikely(rtn == BLK_EH_NOT_HANDLED &&
297-
!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD)))
298-
rtn = BLK_EH_HANDLED;
295+
set_host_byte(scmd, DID_TIME_OUT);
296+
if (!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))
297+
rtn = BLK_EH_HANDLED;
298+
}
299299

300300
return rtn;
301301
}
@@ -1777,7 +1777,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
17771777
break;
17781778
case DID_ABORT:
17791779
if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) {
1780-
scmd->result |= DID_TIME_OUT << 16;
1780+
set_host_byte(scmd, DID_TIME_OUT);
17811781
return SUCCESS;
17821782
}
17831783
case DID_NO_CONNECT:

drivers/scsi/scsi_transport_fc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,7 @@ fc_rport_final_delete(struct work_struct *work)
25492549
fc_flush_devloss(shost);
25502550
if (!cancel_delayed_work(&rport->dev_loss_work))
25512551
fc_flush_devloss(shost);
2552+
cancel_work_sync(&rport->scan_work);
25522553
spin_lock_irqsave(shost->host_lock, flags);
25532554
rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
25542555
}

0 commit comments

Comments
 (0)