Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()

+128 -117
+1
MAINTAINERS
··· 7059 7059 PMC SIERRA PM8001 DRIVER 7060 7060 M: xjtuwjp@gmail.com 7061 7061 M: lindar_liu@usish.com 7062 + L: pmchba@pmcs.com 7062 7063 L: linux-scsi@vger.kernel.org 7063 7064 S: Supported 7064 7065 F: drivers/scsi/pm8001/
+1 -1
drivers/scsi/libiscsi.c
··· 2097 2097 conn->ping_timeout, conn->recv_timeout, 2098 2098 last_recv, conn->last_ping, jiffies); 2099 2099 spin_unlock(&session->frwd_lock); 2100 - iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 2100 + iscsi_conn_failure(conn, ISCSI_ERR_NOP_TIMEDOUT); 2101 2101 return; 2102 2102 } 2103 2103
+73 -77
drivers/scsi/pm8001/pm8001_ctl.c
··· 526 526 { 527 527 struct pm8001_ioctl_payload *payload; 528 528 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 532 533 - length = 1024 * 5 + sizeof(*payload) - 1; 533 + if (pm8001_ha->fw_image->size > 4096) { 534 + pm8001_ha->fw_status = FAIL_FILE_SIZE; 535 + return -EFAULT; 536 + } 537 + 534 538 ioctlbuffer = kzalloc(length, GFP_KERNEL); 535 - if (!ioctlbuffer) 539 + if (!ioctlbuffer) { 540 + pm8001_ha->fw_status = FAIL_OUT_MEMORY; 536 541 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; 541 542 } 542 543 payload = (struct pm8001_ioctl_payload *)ioctlbuffer; 543 544 memcpy((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data, ··· 548 547 payload->minor_function = 0x1; 549 548 pm8001_ha->nvmd_completion = &completion; 550 549 ret = PM8001_CHIP_DISP->set_nvmd_req(pm8001_ha, payload); 550 + if (ret) { 551 + pm8001_ha->fw_status = FAIL_OUT_MEMORY; 552 + goto out; 553 + } 551 554 wait_for_completion(&completion); 552 555 out: 553 556 kfree(ioctlbuffer); ··· 562 557 { 563 558 struct pm8001_ioctl_payload *payload; 564 559 DECLARE_COMPLETION_ONSTACK(completion); 565 - u8 *ioctlbuffer = NULL; 566 - u32 length = 0; 560 + u8 *ioctlbuffer; 567 561 struct fw_control_info *fwControl; 568 - u32 loopNumber, loopcount = 0; 569 - u32 sizeRead = 0; 570 562 u32 partitionSize, partitionSizeTmp; 571 - u32 ret = 0; 572 - u32 partitionNumber = 0; 563 + u32 loopNumber, loopcount; 573 564 struct pm8001_fw_image_header *image_hdr; 565 + u32 sizeRead = 0; 566 + u32 ret = 0; 567 + u32 length = 1024 * 16 + sizeof(*payload) - 1; 574 568 575 - length = 1024 * 16 + sizeof(*payload) - 1; 576 - ioctlbuffer = kzalloc(length, GFP_KERNEL); 577 - image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; 578 - if (!ioctlbuffer) 579 - return -ENOMEM; 580 569 if (pm8001_ha->fw_image->size < 28) { 581 - ret = FAIL_FILE_SIZE; 582 - goto out; 570 + pm8001_ha->fw_status = FAIL_FILE_SIZE; 571 + return -EFAULT; 583 572 } 584 - 573 + ioctlbuffer = kzalloc(length, GFP_KERNEL); 574 + if (!ioctlbuffer) { 575 + pm8001_ha->fw_status = FAIL_OUT_MEMORY; 576 + return -ENOMEM; 577 + } 578 + image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; 585 579 while (sizeRead < pm8001_ha->fw_image->size) { 586 580 partitionSizeTmp = 587 581 *(u32 *)((u8 *)&image_hdr->image_length + sizeRead); 588 582 partitionSize = be32_to_cpu(partitionSizeTmp); 589 - loopcount = (partitionSize + HEADER_LEN)/IOCTL_BUF_SIZE; 590 - if (loopcount % IOCTL_BUF_SIZE) 591 - loopcount++; 592 - if (loopcount == 0) 593 - loopcount++; 583 + loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN, 584 + IOCTL_BUF_SIZE); 594 585 for (loopNumber = 0; loopNumber < loopcount; loopNumber++) { 595 586 payload = (struct pm8001_ioctl_payload *)ioctlbuffer; 596 587 payload->length = 1024*16; ··· 618 617 619 618 pm8001_ha->nvmd_completion = &completion; 620 619 ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload); 621 - if (ret) 622 - break; 620 + if (ret) { 621 + pm8001_ha->fw_status = FAIL_OUT_MEMORY; 622 + goto out; 623 + } 623 624 wait_for_completion(&completion); 624 625 if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) { 625 - ret = fwControl->retcode; 626 - break; 626 + pm8001_ha->fw_status = fwControl->retcode; 627 + ret = -EFAULT; 628 + goto out; 629 + } 627 630 } 628 631 } 629 - if (ret) 630 - break; 631 - partitionNumber++; 632 - } 633 632 out: 634 633 kfree(ioctlbuffer); 635 634 return ret; ··· 644 643 char *cmd_ptr, *filename_ptr; 645 644 int res, i; 646 645 int flash_command = FLASH_CMD_NONE; 647 - int err = 0; 646 + int ret; 647 + 648 648 if (!capable(CAP_SYS_ADMIN)) 649 649 return -EACCES; 650 650 651 - cmd_ptr = kzalloc(count*2, GFP_KERNEL); 651 + /* this test protects us from running two flash processes at once, 652 + * so we should start with this test */ 653 + if (pm8001_ha->fw_status == FLASH_IN_PROGRESS) 654 + return -EINPROGRESS; 655 + pm8001_ha->fw_status = FLASH_IN_PROGRESS; 652 656 657 + cmd_ptr = kzalloc(count*2, GFP_KERNEL); 653 658 if (!cmd_ptr) { 654 - err = FAIL_OUT_MEMORY; 655 - goto out; 659 + pm8001_ha->fw_status = FAIL_OUT_MEMORY; 660 + return -ENOMEM; 656 661 } 657 662 658 663 filename_ptr = cmd_ptr + count; 659 664 res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr); 660 665 if (res != 2) { 661 - err = FAIL_PARAMETERS; 662 - goto out1; 666 + pm8001_ha->fw_status = FAIL_PARAMETERS; 667 + ret = -EINVAL; 668 + goto out; 663 669 } 664 670 665 671 for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) { ··· 677 669 } 678 670 } 679 671 if (flash_command == FLASH_CMD_NONE) { 680 - err = FAIL_PARAMETERS; 681 - goto out1; 672 + pm8001_ha->fw_status = FAIL_PARAMETERS; 673 + ret = -EINVAL; 674 + goto out; 682 675 } 683 676 684 - if (pm8001_ha->fw_status == FLASH_IN_PROGRESS) { 685 - err = FLASH_IN_PROGRESS; 686 - goto out1; 687 - } 688 - err = request_firmware(&pm8001_ha->fw_image, 677 + ret = request_firmware(&pm8001_ha->fw_image, 689 678 filename_ptr, 690 679 pm8001_ha->dev); 691 680 692 - if (err) { 681 + if (ret) { 693 682 PM8001_FAIL_DBG(pm8001_ha, 694 - pm8001_printk("Failed to load firmware image file %s," 695 - " error %d\n", filename_ptr, err)); 696 - err = FAIL_OPEN_BIOS_FILE; 697 - goto out1; 683 + pm8001_printk( 684 + "Failed to load firmware image file %s, error %d\n", 685 + filename_ptr, ret)); 686 + pm8001_ha->fw_status = FAIL_OPEN_BIOS_FILE; 687 + goto out; 698 688 } 699 689 700 - switch (flash_command) { 701 - case FLASH_CMD_UPDATE: 702 - pm8001_ha->fw_status = FLASH_IN_PROGRESS; 703 - err = pm8001_update_flash(pm8001_ha); 704 - break; 705 - case FLASH_CMD_SET_NVMD: 706 - pm8001_ha->fw_status = FLASH_IN_PROGRESS; 707 - err = pm8001_set_nvmd(pm8001_ha); 708 - break; 709 - default: 710 - pm8001_ha->fw_status = FAIL_PARAMETERS; 711 - err = FAIL_PARAMETERS; 712 - break; 713 - } 714 - release_firmware(pm8001_ha->fw_image); 715 - out1: 716 - kfree(cmd_ptr); 717 - out: 718 - pm8001_ha->fw_status = err; 719 - 720 - if (!err) 721 - return count; 690 + if (FLASH_CMD_UPDATE == flash_command) 691 + ret = pm8001_update_flash(pm8001_ha); 722 692 else 723 - return -err; 693 + ret = pm8001_set_nvmd(pm8001_ha); 694 + 695 + release_firmware(pm8001_ha->fw_image); 696 + out: 697 + kfree(cmd_ptr); 698 + 699 + if (ret) 700 + return ret; 701 + 702 + pm8001_ha->fw_status = FLASH_OK; 703 + return count; 724 704 } 725 705 726 706 static ssize_t pm8001_show_update_fw(struct device *cdev,
+2 -2
drivers/scsi/pm8001/pm8001_hwi.c
··· 4824 4824 rc = pm8001_tag_alloc(pm8001_ha, &tag); 4825 4825 if (rc) { 4826 4826 kfree(fw_control_context); 4827 - return rc; 4827 + return -EBUSY; 4828 4828 } 4829 4829 ccb = &pm8001_ha->ccb_info[tag]; 4830 4830 ccb->fw_control_context = fw_control_context; ··· 4946 4946 rc = pm8001_tag_alloc(pm8001_ha, &tag); 4947 4947 if (rc) { 4948 4948 kfree(fw_control_context); 4949 - return rc; 4949 + return -EBUSY; 4950 4950 } 4951 4951 ccb = &pm8001_ha->ccb_info[tag]; 4952 4952 ccb->fw_control_context = fw_control_context;
+20 -19
drivers/scsi/pm8001/pm8001_init.c
··· 748 748 sizeof(pm8001_ha->msix_entries[0]); 749 749 for (i = 0; i < max_entry ; i++) 750 750 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, 752 752 number_of_intr); 753 753 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; 758 756 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)); 759 760 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; 765 766 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, 773 773 &(pm8001_ha->irq_vector[i])); 774 - pci_disable_msix(pm8001_ha->pdev); 775 - break; 776 774 } 775 + pci_disable_msix(pm8001_ha->pdev); 776 + break; 777 777 } 778 778 } 779 + 779 780 return rc; 780 781 } 781 782 #endif
+6
drivers/scsi/qla4xxx/ql4_init.c
··· 334 334 /* Allocate memory for saving the template */ 335 335 md_tmp = dma_alloc_coherent(&ha->pdev->dev, ha->fw_dump_tmplt_size, 336 336 &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 + } 337 343 338 344 /* Request template */ 339 345 status = qla4xxx_get_minidump_template(ha, md_tmp_dma);
+7 -7
drivers/scsi/qla4xxx/ql4_mbx.c
··· 1620 1620 goto exit_get_chap; 1621 1621 } 1622 1622 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); 1625 1625 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE); 1626 1626 1627 1627 exit_get_chap: ··· 1663 1663 else 1664 1664 chap_table->flags |= BIT_7; /* local */ 1665 1665 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); 1668 1668 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE); 1669 1669 1670 1670 if (is_qla40XX(ha)) { ··· 1742 1742 goto exit_unlock_uni_chap; 1743 1743 } 1744 1744 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); 1747 1747 1748 1748 rval = QLA_SUCCESS; 1749 1749 ··· 2295 2295 if (param == SET_DRVR_VERSION) { 2296 2296 mbox_cmd[1] = SET_DRVR_VERSION; 2297 2297 strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION, 2298 - MAX_DRVR_VER_LEN); 2298 + MAX_DRVR_VER_LEN - 1); 2299 2299 } else { 2300 2300 ql4_printk(KERN_ERR, ha, "%s: invalid parameter 0x%x\n", 2301 2301 __func__, param);
+1 -1
drivers/scsi/qla4xxx/ql4_nx.c
··· 4221 4221 for (i = 0; i < QLA_MSIX_ENTRIES; i++) 4222 4222 entries[i].entry = qla4_8xxx_msix_entries[i].entry; 4223 4223 4224 - ret = pci_enable_msix(ha->pdev, entries, ARRAY_SIZE(entries)); 4224 + ret = pci_enable_msix_exact(ha->pdev, entries, ARRAY_SIZE(entries)); 4225 4225 if (ret) { 4226 4226 ql4_printk(KERN_WARNING, ha, 4227 4227 "MSI-X: Failed to enable support -- %d/%d\n",
+9 -7
drivers/scsi/qla4xxx/ql4_os.c
··· 756 756 continue; 757 757 758 758 chap_rec->chap_tbl_idx = i; 759 - strncpy(chap_rec->username, chap_table->name, 759 + strlcpy(chap_rec->username, chap_table->name, 760 760 ISCSI_CHAP_AUTH_NAME_MAX_LEN); 761 - strncpy(chap_rec->password, chap_table->secret, 761 + strlcpy(chap_rec->password, chap_table->secret, 762 762 QL4_CHAP_MAX_SECRET_LEN); 763 763 chap_rec->password_length = chap_table->secret_len; 764 764 ··· 1050 1050 if (!ql_iscsi_stats) { 1051 1051 ql4_printk(KERN_ERR, ha, 1052 1052 "Unable to allocate memory for iscsi stats\n"); 1053 + ret = -ENOMEM; 1053 1054 goto exit_host_stats; 1054 1055 } 1055 1056 ··· 1059 1058 if (ret != QLA_SUCCESS) { 1060 1059 ql4_printk(KERN_ERR, ha, 1061 1060 "Unable to retrieve iscsi stats\n"); 1061 + ret = -EIO; 1062 1062 goto exit_host_stats; 1063 1063 } 1064 1064 host_stats->mactx_frames = le64_to_cpu(ql_iscsi_stats->mac_tx_frames); ··· 6029 6027 if (!(chap_table->flags & BIT_6)) /* Not BIDI */ 6030 6028 continue; 6031 6029 6032 - strncpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN); 6033 - strncpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN); 6030 + strlcpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN); 6031 + strlcpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN); 6034 6032 ret = 0; 6035 6033 break; 6036 6034 } ··· 6260 6258 6261 6259 tddb->tpgt = sess->tpgt; 6262 6260 tddb->port = conn->persistent_port; 6263 - strncpy(tddb->iscsi_name, sess->targetname, ISCSI_NAME_SIZE); 6264 - strncpy(tddb->ip_addr, conn->persistent_address, DDB_IPADDR_LEN); 6261 + strlcpy(tddb->iscsi_name, sess->targetname, ISCSI_NAME_SIZE); 6262 + strlcpy(tddb->ip_addr, conn->persistent_address, DDB_IPADDR_LEN); 6265 6263 } 6266 6264 6267 6265 static void qla4xxx_convert_param_ddb(struct dev_db_entry *fw_ddb_entry, ··· 7766 7764 goto exit_ddb_logout; 7767 7765 } 7768 7766 7769 - strncpy(flash_tddb->iscsi_name, fnode_sess->targetname, 7767 + strlcpy(flash_tddb->iscsi_name, fnode_sess->targetname, 7770 7768 ISCSI_NAME_SIZE); 7771 7769 7772 7770 if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
+5 -1
drivers/scsi/scsi_transport_iscsi.c
··· 3429 3429 char *buf; 3430 3430 3431 3431 if (!transport->get_host_stats) 3432 - return -EINVAL; 3432 + return -ENOSYS; 3433 3433 3434 3434 priv = iscsi_if_transport_lookup(transport); 3435 3435 if (!priv) ··· 3467 3467 memset(buf, 0, host_stats_size); 3468 3468 3469 3469 err = transport->get_host_stats(shost, buf, host_stats_size); 3470 + if (err) { 3471 + kfree_skb(skbhost_stats); 3472 + goto exit_host_stats; 3473 + } 3470 3474 3471 3475 actual_size = nlmsg_total_size(sizeof(*ev) + host_stats_size); 3472 3476 skb_trim(skbhost_stats, NLMSG_ALIGN(actual_size));
+2 -2
drivers/scsi/u14-34f.c
··· 1006 1006 sh[j]->irq, dma_name, sh[j]->sg_tablesize, sh[j]->can_queue); 1007 1007 1008 1008 if (sh[j]->max_id > 8 || sh[j]->max_lun > 8) 1009 - printk("%s: wide SCSI support enabled, max_id %u, max_lun %u.\n", 1009 + printk("%s: wide SCSI support enabled, max_id %u, max_lun %llu.\n", 1010 1010 BN(j), sh[j]->max_id, sh[j]->max_lun); 1011 1011 1012 1012 for (i = 0; i <= sh[j]->max_channel; i++) ··· 1285 1285 cpp->cpp_index = i; 1286 1286 SCpnt->host_scribble = (unsigned char *) &cpp->cpp_index; 1287 1287 1288 - if (do_trace) printk("%s: qcomm, mbox %d, target %d.%d:%llu.\n", 1288 + if (do_trace) printk("%s: qcomm, mbox %d, target %d.%d:%u.\n", 1289 1289 BN(j), i, SCpnt->device->channel, SCpnt->device->id, 1290 1290 (u8)SCpnt->device->lun); 1291 1291
+1
include/scsi/iscsi_if.h
··· 527 527 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, 528 528 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, 529 529 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21, 530 + ISCSI_ERR_NOP_TIMEDOUT = ISCSI_ERR_BASE + 22, 530 531 }; 531 532 532 533 /*