Skip to content

Commit 88ec63d

Browse files
committed
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull more SCSI changes from James Bottomley: "This is a small set of updates which missed the first pull. It's more msix updates, some iscsi and qla4xxx fixes, we also have some string null termination fixes a return value fix and a couple of pm8001 firmware fixes. Just a note, we do have a couple of bug fixes coming under separate cover, but they don't have to be part of the merge window" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: iscsi class: Fix freeing of skb in get host error path scsi: fix u14-34f printk format warnings pm8001: fix pm8001_store_update_fw pm8001: Fix erratic calculation in update_flash pm8001: Update MAINTAINERS list libiscsi: return new error code when nop times out iscsi class: fix get_host_stats return code when not supported iscsi class: fix get_host_stats error handling qla4xxx: fix get_host_stats error propagation qla4xxx: check the return value of dma_alloc_coherent() scsi: qla4xxx: ql4_mbx.c: Cleaning up missing null-terminate in conjunction with strncpy scsi: qla4xxx: ql4_os.c: Cleaning up missing null-terminate in conjunction with strncpy qla4xxx: Use pci_enable_msix_exact() instead of pci_enable_msix() pm8001: Use pci_enable_msix_exact() instead of pci_enable_msix()
2 parents 2f39691 + ae87e8b commit 88ec63d

12 files changed

Lines changed: 125 additions & 114 deletions

File tree

‎MAINTAINERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7059,6 +7059,7 @@ F: drivers/scsi/pmcraid.*
70597059
PMC SIERRA PM8001 DRIVER
70607060
M: xjtuwjp@gmail.com
70617061
M: lindar_liu@usish.com
7062+
L: pmchba@pmcs.com
70627063
L: linux-scsi@vger.kernel.org
70637064
S: Supported
70647065
F: drivers/scsi/pm8001/

‎drivers/scsi/libiscsi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ static void iscsi_check_transport_timeouts(unsigned long data)
20972097
conn->ping_timeout, conn->recv_timeout,
20982098
last_recv, conn->last_ping, jiffies);
20992099
spin_unlock(&session->frwd_lock);
2100-
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
2100+
iscsi_conn_failure(conn, ISCSI_ERR_NOP_TIMEDOUT);
21012101
return;
21022102
}
21032103

‎drivers/scsi/pm8001/pm8001_ctl.c‎

Lines changed: 70 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,19 @@ static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha)
526526
{
527527
struct pm8001_ioctl_payload *payload;
528528
DECLARE_COMPLETION_ONSTACK(completion);
529-
u8 *ioctlbuffer = NULL;
530-
u32 length = 0;
531-
u32 ret = 0;
529+
u8 *ioctlbuffer;
530+
u32 ret;
531+
u32 length = 1024 * 5 + sizeof(*payload) - 1;
532+
533+
if (pm8001_ha->fw_image->size > 4096) {
534+
pm8001_ha->fw_status = FAIL_FILE_SIZE;
535+
return -EFAULT;
536+
}
532537

533-
length = 1024 * 5 + sizeof(*payload) - 1;
534538
ioctlbuffer = kzalloc(length, GFP_KERNEL);
535-
if (!ioctlbuffer)
539+
if (!ioctlbuffer) {
540+
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
536541
return -ENOMEM;
537-
if ((pm8001_ha->fw_image->size <= 0) ||
538-
(pm8001_ha->fw_image->size > 4096)) {
539-
ret = FAIL_FILE_SIZE;
540-
goto out;
541542
}
542543
payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
543544
memcpy((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data,
@@ -547,6 +548,10 @@ static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha)
547548
payload->minor_function = 0x1;
548549
pm8001_ha->nvmd_completion = &completion;
549550
ret = PM8001_CHIP_DISP->set_nvmd_req(pm8001_ha, payload);
551+
if (ret) {
552+
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
553+
goto out;
554+
}
550555
wait_for_completion(&completion);
551556
out:
552557
kfree(ioctlbuffer);
@@ -557,35 +562,31 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
557562
{
558563
struct pm8001_ioctl_payload *payload;
559564
DECLARE_COMPLETION_ONSTACK(completion);
560-
u8 *ioctlbuffer = NULL;
561-
u32 length = 0;
565+
u8 *ioctlbuffer;
562566
struct fw_control_info *fwControl;
563-
u32 loopNumber, loopcount = 0;
564-
u32 sizeRead = 0;
565567
u32 partitionSize, partitionSizeTmp;
566-
u32 ret = 0;
567-
u32 partitionNumber = 0;
568+
u32 loopNumber, loopcount;
568569
struct pm8001_fw_image_header *image_hdr;
570+
u32 sizeRead = 0;
571+
u32 ret = 0;
572+
u32 length = 1024 * 16 + sizeof(*payload) - 1;
569573

570-
length = 1024 * 16 + sizeof(*payload) - 1;
574+
if (pm8001_ha->fw_image->size < 28) {
575+
pm8001_ha->fw_status = FAIL_FILE_SIZE;
576+
return -EFAULT;
577+
}
571578
ioctlbuffer = kzalloc(length, GFP_KERNEL);
572-
image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data;
573-
if (!ioctlbuffer)
579+
if (!ioctlbuffer) {
580+
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
574581
return -ENOMEM;
575-
if (pm8001_ha->fw_image->size < 28) {
576-
ret = FAIL_FILE_SIZE;
577-
goto out;
578582
}
579-
583+
image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data;
580584
while (sizeRead < pm8001_ha->fw_image->size) {
581585
partitionSizeTmp =
582586
*(u32 *)((u8 *)&image_hdr->image_length + sizeRead);
583587
partitionSize = be32_to_cpu(partitionSizeTmp);
584-
loopcount = (partitionSize + HEADER_LEN)/IOCTL_BUF_SIZE;
585-
if (loopcount % IOCTL_BUF_SIZE)
586-
loopcount++;
587-
if (loopcount == 0)
588-
loopcount++;
588+
loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN,
589+
IOCTL_BUF_SIZE);
589590
for (loopNumber = 0; loopNumber < loopcount; loopNumber++) {
590591
payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
591592
payload->length = 1024*16;
@@ -617,18 +618,18 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
617618

618619
pm8001_ha->nvmd_completion = &completion;
619620
ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload);
620-
if (ret)
621-
break;
621+
if (ret) {
622+
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
623+
goto out;
624+
}
622625
wait_for_completion(&completion);
623626
if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
624-
ret = fwControl->retcode;
625-
break;
627+
pm8001_ha->fw_status = fwControl->retcode;
628+
ret = -EFAULT;
629+
goto out;
630+
}
626631
}
627632
}
628-
if (ret)
629-
break;
630-
partitionNumber++;
631-
}
632633
out:
633634
kfree(ioctlbuffer);
634635
return ret;
@@ -643,22 +644,29 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
643644
char *cmd_ptr, *filename_ptr;
644645
int res, i;
645646
int flash_command = FLASH_CMD_NONE;
646-
int err = 0;
647+
int ret;
648+
647649
if (!capable(CAP_SYS_ADMIN))
648650
return -EACCES;
649651

650-
cmd_ptr = kzalloc(count*2, GFP_KERNEL);
652+
/* this test protects us from running two flash processes at once,
653+
* so we should start with this test */
654+
if (pm8001_ha->fw_status == FLASH_IN_PROGRESS)
655+
return -EINPROGRESS;
656+
pm8001_ha->fw_status = FLASH_IN_PROGRESS;
651657

658+
cmd_ptr = kzalloc(count*2, GFP_KERNEL);
652659
if (!cmd_ptr) {
653-
err = FAIL_OUT_MEMORY;
654-
goto out;
660+
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
661+
return -ENOMEM;
655662
}
656663

657664
filename_ptr = cmd_ptr + count;
658665
res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr);
659666
if (res != 2) {
660-
err = FAIL_PARAMETERS;
661-
goto out1;
667+
pm8001_ha->fw_status = FAIL_PARAMETERS;
668+
ret = -EINVAL;
669+
goto out;
662670
}
663671

664672
for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) {
@@ -669,50 +677,38 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
669677
}
670678
}
671679
if (flash_command == FLASH_CMD_NONE) {
672-
err = FAIL_PARAMETERS;
673-
goto out1;
680+
pm8001_ha->fw_status = FAIL_PARAMETERS;
681+
ret = -EINVAL;
682+
goto out;
674683
}
675684

676-
if (pm8001_ha->fw_status == FLASH_IN_PROGRESS) {
677-
err = FLASH_IN_PROGRESS;
678-
goto out1;
679-
}
680-
err = request_firmware(&pm8001_ha->fw_image,
685+
ret = request_firmware(&pm8001_ha->fw_image,
681686
filename_ptr,
682687
pm8001_ha->dev);
683688

684-
if (err) {
689+
if (ret) {
685690
PM8001_FAIL_DBG(pm8001_ha,
686-
pm8001_printk("Failed to load firmware image file %s,"
687-
" error %d\n", filename_ptr, err));
688-
err = FAIL_OPEN_BIOS_FILE;
689-
goto out1;
691+
pm8001_printk(
692+
"Failed to load firmware image file %s, error %d\n",
693+
filename_ptr, ret));
694+
pm8001_ha->fw_status = FAIL_OPEN_BIOS_FILE;
695+
goto out;
690696
}
691697

692-
switch (flash_command) {
693-
case FLASH_CMD_UPDATE:
694-
pm8001_ha->fw_status = FLASH_IN_PROGRESS;
695-
err = pm8001_update_flash(pm8001_ha);
696-
break;
697-
case FLASH_CMD_SET_NVMD:
698-
pm8001_ha->fw_status = FLASH_IN_PROGRESS;
699-
err = pm8001_set_nvmd(pm8001_ha);
700-
break;
701-
default:
702-
pm8001_ha->fw_status = FAIL_PARAMETERS;
703-
err = FAIL_PARAMETERS;
704-
break;
705-
}
698+
if (FLASH_CMD_UPDATE == flash_command)
699+
ret = pm8001_update_flash(pm8001_ha);
700+
else
701+
ret = pm8001_set_nvmd(pm8001_ha);
702+
706703
release_firmware(pm8001_ha->fw_image);
707-
out1:
708-
kfree(cmd_ptr);
709704
out:
710-
pm8001_ha->fw_status = err;
705+
kfree(cmd_ptr);
711706

712-
if (!err)
713-
return count;
714-
else
715-
return -err;
707+
if (ret)
708+
return ret;
709+
710+
pm8001_ha->fw_status = FLASH_OK;
711+
return count;
716712
}
717713

718714
static ssize_t pm8001_show_update_fw(struct device *cdev,

‎drivers/scsi/pm8001/pm8001_hwi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4824,7 +4824,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
48244824
rc = pm8001_tag_alloc(pm8001_ha, &tag);
48254825
if (rc) {
48264826
kfree(fw_control_context);
4827-
return rc;
4827+
return -EBUSY;
48284828
}
48294829
ccb = &pm8001_ha->ccb_info[tag];
48304830
ccb->fw_control_context = fw_control_context;
@@ -4946,7 +4946,7 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
49464946
rc = pm8001_tag_alloc(pm8001_ha, &tag);
49474947
if (rc) {
49484948
kfree(fw_control_context);
4949-
return rc;
4949+
return -EBUSY;
49504950
}
49514951
ccb = &pm8001_ha->ccb_info[tag];
49524952
ccb->fw_control_context = fw_control_context;

‎drivers/scsi/pm8001/pm8001_init.c‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -748,34 +748,35 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
748748
sizeof(pm8001_ha->msix_entries[0]);
749749
for (i = 0; i < max_entry ; i++)
750750
pm8001_ha->msix_entries[i].entry = i;
751-
rc = pci_enable_msix(pm8001_ha->pdev, pm8001_ha->msix_entries,
751+
rc = pci_enable_msix_exact(pm8001_ha->pdev, pm8001_ha->msix_entries,
752752
number_of_intr);
753753
pm8001_ha->number_of_intr = number_of_intr;
754-
if (!rc) {
755-
PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
756-
"pci_enable_msix request ret:%d no of intr %d\n",
757-
rc, pm8001_ha->number_of_intr));
754+
if (rc)
755+
return rc;
758756

757+
PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
758+
"pci_enable_msix_exact request ret:%d no of intr %d\n",
759+
rc, pm8001_ha->number_of_intr));
759760

760-
for (i = 0; i < number_of_intr; i++) {
761-
snprintf(intr_drvname[i], sizeof(intr_drvname[0]),
762-
DRV_NAME"%d", i);
763-
pm8001_ha->irq_vector[i].irq_id = i;
764-
pm8001_ha->irq_vector[i].drv_inst = pm8001_ha;
761+
for (i = 0; i < number_of_intr; i++) {
762+
snprintf(intr_drvname[i], sizeof(intr_drvname[0]),
763+
DRV_NAME"%d", i);
764+
pm8001_ha->irq_vector[i].irq_id = i;
765+
pm8001_ha->irq_vector[i].drv_inst = pm8001_ha;
765766

766-
rc = request_irq(pm8001_ha->msix_entries[i].vector,
767-
pm8001_interrupt_handler_msix, flag,
768-
intr_drvname[i], &(pm8001_ha->irq_vector[i]));
769-
if (rc) {
770-
for (j = 0; j < i; j++)
771-
free_irq(
772-
pm8001_ha->msix_entries[j].vector,
767+
rc = request_irq(pm8001_ha->msix_entries[i].vector,
768+
pm8001_interrupt_handler_msix, flag,
769+
intr_drvname[i], &(pm8001_ha->irq_vector[i]));
770+
if (rc) {
771+
for (j = 0; j < i; j++) {
772+
free_irq(pm8001_ha->msix_entries[j].vector,
773773
&(pm8001_ha->irq_vector[i]));
774-
pci_disable_msix(pm8001_ha->pdev);
775-
break;
776774
}
775+
pci_disable_msix(pm8001_ha->pdev);
776+
break;
777777
}
778778
}
779+
779780
return rc;
780781
}
781782
#endif

‎drivers/scsi/qla4xxx/ql4_init.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ void qla4xxx_alloc_fw_dump(struct scsi_qla_host *ha)
334334
/* Allocate memory for saving the template */
335335
md_tmp = dma_alloc_coherent(&ha->pdev->dev, ha->fw_dump_tmplt_size,
336336
&md_tmp_dma, GFP_KERNEL);
337+
if (!md_tmp) {
338+
ql4_printk(KERN_INFO, ha,
339+
"scsi%ld: Failed to allocate DMA memory\n",
340+
ha->host_no);
341+
return;
342+
}
337343

338344
/* Request template */
339345
status = qla4xxx_get_minidump_template(ha, md_tmp_dma);

‎drivers/scsi/qla4xxx/ql4_mbx.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,8 +1620,8 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
16201620
goto exit_get_chap;
16211621
}
16221622

1623-
strncpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
1624-
strncpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
1623+
strlcpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
1624+
strlcpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
16251625
chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE);
16261626

16271627
exit_get_chap:
@@ -1663,8 +1663,8 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
16631663
else
16641664
chap_table->flags |= BIT_7; /* local */
16651665
chap_table->secret_len = strlen(password);
1666-
strncpy(chap_table->secret, password, MAX_CHAP_SECRET_LEN);
1667-
strncpy(chap_table->name, username, MAX_CHAP_NAME_LEN);
1666+
strncpy(chap_table->secret, password, MAX_CHAP_SECRET_LEN - 1);
1667+
strncpy(chap_table->name, username, MAX_CHAP_NAME_LEN - 1);
16681668
chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE);
16691669

16701670
if (is_qla40XX(ha)) {
@@ -1742,8 +1742,8 @@ int qla4xxx_get_uni_chap_at_index(struct scsi_qla_host *ha, char *username,
17421742
goto exit_unlock_uni_chap;
17431743
}
17441744

1745-
strncpy(password, chap_table->secret, MAX_CHAP_SECRET_LEN);
1746-
strncpy(username, chap_table->name, MAX_CHAP_NAME_LEN);
1745+
strlcpy(password, chap_table->secret, MAX_CHAP_SECRET_LEN);
1746+
strlcpy(username, chap_table->name, MAX_CHAP_NAME_LEN);
17471747

17481748
rval = QLA_SUCCESS;
17491749

@@ -2295,7 +2295,7 @@ int qla4_8xxx_set_param(struct scsi_qla_host *ha, int param)
22952295
if (param == SET_DRVR_VERSION) {
22962296
mbox_cmd[1] = SET_DRVR_VERSION;
22972297
strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION,
2298-
MAX_DRVR_VER_LEN);
2298+
MAX_DRVR_VER_LEN - 1);
22992299
} else {
23002300
ql4_printk(KERN_ERR, ha, "%s: invalid parameter 0x%x\n",
23012301
__func__, param);

‎drivers/scsi/qla4xxx/ql4_nx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4221,7 +4221,7 @@ qla4_8xxx_enable_msix(struct scsi_qla_host *ha)
42214221
for (i = 0; i < QLA_MSIX_ENTRIES; i++)
42224222
entries[i].entry = qla4_8xxx_msix_entries[i].entry;
42234223

4224-
ret = pci_enable_msix(ha->pdev, entries, ARRAY_SIZE(entries));
4224+
ret = pci_enable_msix_exact(ha->pdev, entries, ARRAY_SIZE(entries));
42254225
if (ret) {
42264226
ql4_printk(KERN_WARNING, ha,
42274227
"MSI-X: Failed to enable support -- %d/%d\n",

0 commit comments

Comments
 (0)