[PATCH] scsi: lpfc: Fix potential NULL pointer dereference in lpfc_nvme_fcp_io_submit
pnvme_lport is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by null checking pnvme_lport before it is dereferenced. Addresses-Coverity-ID: 1423709 ("Dereference before null check") Fixes: b7672ae681f8 ("scsi: lpfc: Fix crash in lpfc_nvme_fcp_io_submit during LIP") Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- Also, I wonder if the right pointer to check at line: if (!pnvme_rport || !freqpriv) { is pnvme_fcreq instead of freqpriv drivers/scsi/lpfc/lpfc_nvme.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 517ae57..68cba7d 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -1251,6 +1251,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, uint64_t start = 0; #endif + if (!pnvme_lport) { + ret = -ENODEV; + goto out_fail; + } + lport = (struct lpfc_nvme_lport *)pnvme_lport->private; vport = lport->vport; phba = vport->phba; @@ -1261,7 +1266,7 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, } /* Validate pointers. */ - if (!pnvme_lport || !pnvme_rport || !freqpriv) { + if (!pnvme_rport || !freqpriv) { lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, "6117 No Send:IO submit ptrs NULL, lport %p, " "rport %p fcreq_priv %p\n", -- 2.7.4
Re: [PATCH] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg
On 11/21/2017 10:01 PM, Martin K. Petersen wrote: Gustavo A., _vreg_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _vreg_ has been null checked. Applied to 4.15/scsi-fixes, thank you! Glad to help. :) Thanks -- Gustavo A. R. Silva
[PATCH] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg
_vreg_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _vreg_ has been null checked. This issue was detected with the help of Coccinelle. Fixes: aa4976130934 ("ufs: Add regulator enable support") Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/ufs/ufshcd.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 011c336..a355d98 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6559,12 +6559,15 @@ static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { int ret = 0; - struct regulator *reg = vreg->reg; - const char *name = vreg->name; + struct regulator *reg; + const char *name; int min_uV, uA_load; BUG_ON(!vreg); + reg = vreg->reg; + name = vreg->name; + if (regulator_count_voltages(reg) > 0) { min_uV = on ? vreg->min_uV : 0; ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); -- 2.7.4
Re: [PATCH] scsi: bnx2i: bnx2i_hwi: use swap macro in bnx2i_send_iscsi_nopout
Quoting "Rangankar, Manish" <manish.rangan...@cavium.com>: On 04/11/17 1:28 AM, "Gustavo A. R. Silva" <garsi...@embeddedor.com> wrote: Make use of the swap macro and remove unnecessary variable tmp. This makes the code easier to read and maintain. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/bnx2i/bnx2i_hwi.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index e0640e0..9e3bf53 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -547,12 +547,9 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn, nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL; memcpy(nopout_wqe->lun, _hdr->lun, 8); - if (test_bit(BNX2I_NX2_DEV_57710, >hba->cnic_dev_type)) { - u32 tmp = nopout_wqe->lun[0]; - /* 57710 requires LUN field to be swapped */ - nopout_wqe->lun[0] = nopout_wqe->lun[1]; - nopout_wqe->lun[1] = tmp; - } + /* 57710 requires LUN field to be swapped */ + if (test_bit(BNX2I_NX2_DEV_57710, >hba->cnic_dev_type)) + swap(nopout_wqe->lun[0], nopout_wqe->lun[1]); nopout_wqe->itt = ((u16)task->itt | (ISCSI_TASK_TYPE_MPATH << -- 2.7.4 Thanks, Acked-by: Manish Rangankar <manish.rangan...@cavium.com> Thank you, Manish. -- Gustavo A. R. Silva
[PATCH] scsi: aic7xxx_core: remove unnecessary null check before kfree
NULL check before freeing functions like kfree is not needed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index 6612ff3..8d96e11 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -4549,10 +4549,8 @@ ahc_free(struct ahc_softc *ahc) kfree(ahc->black_hole); } #endif - if (ahc->name != NULL) - kfree(ahc->name); - if (ahc->seep_config != NULL) - kfree(ahc->seep_config); + kfree(ahc->name); + kfree(ahc->seep_config); #ifndef __FreeBSD__ kfree(ahc); #endif -- 2.7.4
[PATCH] scsi: ppa: mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Addresses-Coverity-ID: 114988 Addresses-Coverity-ID: 114989 Addresses-Coverity-ID: 114990 Addresses-Coverity-ID: 114991 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/ppa.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 7be5823..ee86a0c 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -724,6 +724,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) return 0; } cmd->SCp.phase++; + /* fall through */ case 3: /* Phase 3 - Ready to accept a command */ w_ctr(ppb, 0x0c); @@ -733,6 +734,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) if (!ppa_send_command(cmd)) return 0; cmd->SCp.phase++; + /* fall through */ case 4: /* Phase 4 - Setup scatter/gather buffers */ if (scsi_bufflen(cmd)) { @@ -746,6 +748,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) } cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; cmd->SCp.phase++; + /* fall through */ case 5: /* Phase 5 - Data transfer stage */ w_ctr(ppb, 0x0c); @@ -758,6 +761,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) if (retv == 0) return 1; cmd->SCp.phase++; + /* fall through */ case 6: /* Phase 6 - Read status/message */ cmd->result = DID_OK << 16; -- 2.7.4
[PATCH] scsi: bnx2i: bnx2i_hwi: use swap macro in bnx2i_send_iscsi_nopout
Make use of the swap macro and remove unnecessary variable tmp. This makes the code easier to read and maintain. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/bnx2i/bnx2i_hwi.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index e0640e0..9e3bf53 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -547,12 +547,9 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn, nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL; memcpy(nopout_wqe->lun, _hdr->lun, 8); - if (test_bit(BNX2I_NX2_DEV_57710, >hba->cnic_dev_type)) { - u32 tmp = nopout_wqe->lun[0]; - /* 57710 requires LUN field to be swapped */ - nopout_wqe->lun[0] = nopout_wqe->lun[1]; - nopout_wqe->lun[1] = tmp; - } + /* 57710 requires LUN field to be swapped */ + if (test_bit(BNX2I_NX2_DEV_57710, >hba->cnic_dev_type)) + swap(nopout_wqe->lun[0], nopout_wqe->lun[1]); nopout_wqe->itt = ((u16)task->itt | (ISCSI_TASK_TYPE_MPATH << -- 2.7.4
[PATCH] scsi: lpfc_els: use swap macro in lpfc_plogi_confirm_nport
Make use of the swap macro and remove unnecessary variable keep_nlp_flag. This makes the code easier to read and maintain. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/lpfc/lpfc_els.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index b14f7c5..1b745fe 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1525,7 +1525,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, struct fc_rport *rport; struct serv_parm *sp; uint8_t name[sizeof(struct lpfc_name)]; - uint32_t rc, keepDID = 0, keep_nlp_flag = 0; + uint32_t rc, keepDID = 0; uint16_t keep_nlp_state; struct lpfc_nvme_rport *keep_nrport = NULL; int put_node; @@ -1616,9 +1616,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, phba->cfg_rrq_xri_bitmap_sz); spin_lock_irq(shost->host_lock); - keep_nlp_flag = new_ndlp->nlp_flag; - new_ndlp->nlp_flag = ndlp->nlp_flag; - ndlp->nlp_flag = keep_nlp_flag; + swap(new_ndlp->nlp_flag, ndlp->nlp_flag); spin_unlock_irq(shost->host_lock); /* Set nlp_states accordingly */ -- 2.7.4
[PATCH] usb: storage: uas: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Addresses-Coverity-ID: 115016 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/usb/storage/uas.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 63cf981..bd4671d 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -668,6 +668,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, break; case DMA_BIDIRECTIONAL: cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB; + /* fall through */ case DMA_TO_DEVICE: cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB; case DMA_NONE: -- 2.7.4
[PATCH] scsi: qla2xxx: remove dead code in qla82xx_write_flash_data
Local variable page_mode is assigned to a constant value and it is never updated again. Remove this variable and the dead code it guards. Addresses-Coverity-ID: 200420 Addresses-Coverity-ID: 114338 Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com> --- This code was tested by compilation only. Also, notice that this code has not been updated since 2010. drivers/scsi/qla2xxx/qla_nx.c | 54 ++- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index a77c339..d5c3d36 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -2676,33 +2676,14 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, int ret; uint32_t liter; uint32_t rest_addr; - dma_addr_t optrom_dma; - void *optrom = NULL; - int page_mode = 0; struct qla_hw_data *ha = vha->hw; - ret = -1; - - /* Prepare burst-capable write on supported ISPs. */ - if (page_mode && !(faddr & 0xfff) && - dwords > OPTROM_BURST_DWORDS) { - optrom = dma_alloc_coherent(>pdev->dev, OPTROM_BURST_SIZE, - _dma, GFP_KERNEL); - if (!optrom) { - ql_log(ql_log_warn, vha, 0xb01b, - "Unable to allocate memory " - "for optrom burst write (%x KB).\n", - OPTROM_BURST_SIZE / 1024); - } - } - rest_addr = ha->fdt_block_size - 1; - ret = qla82xx_unprotect_flash(ha); if (ret) { ql_log(ql_log_warn, vha, 0xb01c, "Unable to unprotect flash for update.\n"); - goto write_done; + return ret; } for (liter = 0; liter < dwords; liter++, faddr += 4, dwptr++) { @@ -2718,34 +2699,6 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, } } - /* Go with burst-write. */ - if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { - /* Copy data to DMA'ble buffer. */ - memcpy(optrom, dwptr, OPTROM_BURST_SIZE); - - ret = qla2x00_load_ram(vha, optrom_dma, - (ha->flash_data_off | faddr), - OPTROM_BURST_DWORDS); - if (ret != QLA_SUCCESS) { - ql_log(ql_log_warn, vha, 0xb01e, - "Unable to burst-write optrom segment " - "(%x/%x/%llx).\n", ret, - (ha->flash_data_off | faddr), - (unsigned long long)optrom_dma); - ql_log(ql_log_warn, vha, 0xb01f, - "Reverting to slow-write.\n"); - - dma_free_coherent(>pdev->dev, - OPTROM_BURST_SIZE, optrom, optrom_dma); - optrom = NULL; - } else { - liter += OPTROM_BURST_DWORDS - 1; - faddr += OPTROM_BURST_DWORDS - 1; - dwptr += OPTROM_BURST_DWORDS - 1; - continue; - } - } - ret = qla82xx_write_flash_dword(ha, faddr, cpu_to_le32(*dwptr)); if (ret) { @@ -2760,10 +2713,7 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, if (ret) ql_log(ql_log_warn, vha, 0xb021, "Unable to protect flash after update.\n"); -write_done: - if (optrom) - dma_free_coherent(>pdev->dev, - OPTROM_BURST_SIZE, optrom, optrom_dma); + return ret; } -- 2.7.4
Re: [PATCH] scsi: lpfc: remove useless code in lpfc_sli4_bsg_link_diag_test
Hi Martin, On 08/23/2017 09:45 PM, Martin K. Petersen wrote: Gustavo, Remove variable assignments. The value stored in local variable _rc_ is overwritten at line 2448:rc = lpfc_sli4_bsg_set_link_diag_state(phba, 0); before it can be used. Applied to 4.14/scsi-queue. Thank you! Glad to help. :) -- Gustavo A. R. Silva
[PATCH] scsi: lpfc: remove useless code in lpfc_sli4_bsg_link_diag_test
Remove variable assignments. The value stored in local variable _rc_ is overwritten at line 2448:rc = lpfc_sli4_bsg_set_link_diag_state(phba, 0); before it can be used. Addresses-Coverity-ID: 1226935 Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com> --- This issue was detected by Coverity and it was tested by compilation only. Notice that this code has been there since 2011. drivers/scsi/lpfc/lpfc_bsg.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index a1686c2..fe9e1c0 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -2384,20 +2384,17 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_job *job) goto job_error; pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); - if (!pmboxq) { - rc = -ENOMEM; + if (!pmboxq) goto link_diag_test_exit; - } req_len = (sizeof(struct lpfc_mbx_set_link_diag_state) - sizeof(struct lpfc_sli4_cfg_mhdr)); alloc_len = lpfc_sli4_config(phba, pmboxq, LPFC_MBOX_SUBSYSTEM_FCOE, LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_STATE, req_len, LPFC_SLI4_MBX_EMBED); - if (alloc_len != req_len) { - rc = -ENOMEM; + if (alloc_len != req_len) goto link_diag_test_exit; - } + run_link_diag_test = >u.mqe.un.link_diag_test; bf_set(lpfc_mbx_run_diag_test_link_num, _link_diag_test->u.req, phba->sli4_hba.lnk_info.lnk_no); -- 2.5.0
[PATCH] scsi: pmcraid: fix duplicated code for different branches
Refactor code in order to avoid identical code for different branches. This issue was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com> --- This code was tested by compilation only. drivers/scsi/pmcraid.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 1f8b153..b4d6cd8 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -1595,12 +1595,7 @@ static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance) if (pinstance->ccn.hcam->notification_type == NOTIFICATION_TYPE_ENTRY_CHANGED && cfg_entry->resource_type == RES_TYPE_VSET) { - - if (fw_version <= PMCRAID_FW_VERSION_1) - hidden_entry = (cfg_entry->unique_flags1 & 0x80) != 0; - else - hidden_entry = (cfg_entry->unique_flags1 & 0x80) != 0; - + hidden_entry = (cfg_entry->unique_flags1 & 0x80) != 0; } else if (!pmcraid_expose_resource(fw_version, cfg_entry)) { goto out_notify_apps; } -- 2.5.0
[PATCH] scsi: mpt3sas_scsih: remove unnecessary statics
Remove unnecessary static on local variables raid_device. Such variables are initialized before being used, on every execution path throughout the functions. The static has no benefit and, removing it reduces the object file size. This issue was detected using Coccinelle and the following semantic patch: @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; In the following log you can see a significant difference in the object file size. This log is the output of the size command, before and after the code change: before: textdata bss dec hex filename 126304 303841280 157968 26910 drivers/scsi/mpt3sas/mpt3sas_scsih.o after: textdata bss dec hex filename 126292 302401152 157684 267f4 drivers/scsi/mpt3sas/mpt3sas_scsih.o Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com> --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 22998cb..417e5d1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1571,7 +1571,7 @@ scsih_get_resync(struct device *dev) { struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; Mpi2RaidVolPage0_t vol_pg0; Mpi2ConfigReply_t mpi_reply; @@ -1632,7 +1632,7 @@ scsih_get_state(struct device *dev) { struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; Mpi2RaidVolPage0_t vol_pg0; Mpi2ConfigReply_t mpi_reply; @@ -7027,7 +7027,7 @@ _scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc, Mpi2EventDataIrOperationStatus_t *event_data = (Mpi2EventDataIrOperationStatus_t *) fw_event->event_data; - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; u16 handle; @@ -7531,7 +7531,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) u64 sas_address; struct _sas_device *sas_device; struct _sas_node *expander_device; - static struct _raid_device *raid_device; + struct _raid_device *raid_device; u8 retry_count; unsigned long flags; -- 2.5.0
[PATCH] scsi: mpt3sas: remove unnecessary statics
Remove unnecessary static on local variable raid_device in functions scsih_get_resync(), scsih_get_state(),_scsih_sas_ir_operation_status_event(), and _scsih_scan_for_devices_after_reset(). Such variables are initialized before being used, on every execution path throughout the mentioned functions. The statics have no benefit and, removing them reduce the code size. This issue was detected using Coccinelle and the following semantic patch: @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; In the following log you can see the difference in the code size. This log is the output of the size command, before and after the code change: before: textdata bss dec hex filename 126304 303841280 157968 26910 drivers/scsi/mpt3sas/mpt3sas_scsih.o after: text data bss dec hex filename 126292 302401152 157684 267f4 drivers/scsi/mpt3sas/mpt3sas_scsih.o Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 22998cb..417e5d1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1571,7 +1571,7 @@ scsih_get_resync(struct device *dev) { struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; Mpi2RaidVolPage0_t vol_pg0; Mpi2ConfigReply_t mpi_reply; @@ -1632,7 +1632,7 @@ scsih_get_state(struct device *dev) { struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; Mpi2RaidVolPage0_t vol_pg0; Mpi2ConfigReply_t mpi_reply; @@ -7027,7 +7027,7 @@ _scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc, Mpi2EventDataIrOperationStatus_t *event_data = (Mpi2EventDataIrOperationStatus_t *) fw_event->event_data; - static struct _raid_device *raid_device; + struct _raid_device *raid_device; unsigned long flags; u16 handle; @@ -7531,7 +7531,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) u64 sas_address; struct _sas_device *sas_device; struct _sas_node *expander_device; - static struct _raid_device *raid_device; + struct _raid_device *raid_device; u8 retry_count; unsigned long flags; -- 2.5.0
[PATCH] scsi: osst: remove useless variable assignments in osst_int_ioctl()
Value assigned to variable blkno at lines 4123:if (blkno >= 0) blkno += arg; and 4127:if (blkno >= 0) blkno -= arg; is overwritten at line 4131:blkno = STps->drv_block; before it can be used. This makes such variable assignments useless. Addresses-Coverity-ID: 1397685 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/osst.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 929ee7e..a62c1f2 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -4118,14 +4118,11 @@ static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt, printk(OSST_DEB_MSG "%s:D: Skipping %lu blocks %s from logical block %d\n", name, arg, cmd_in==MTFSR?"forward":"backward", logical_blk_num); #endif - if (cmd_in == MTFSR) { - logical_blk_num += arg; - if (blkno >= 0) blkno += arg; - } - else { - logical_blk_num -= arg; - if (blkno >= 0) blkno -= arg; - } + if (cmd_in == MTFSR) + logical_blk_num += arg; + else + logical_blk_num -= arg; + ioctl_result = osst_seek_logical_blk(STp, , logical_blk_num); fileno = STps->drv_file; blkno = STps->drv_block; -- 2.5.0
[PATCH] scsi: ipr: remove unnecessary variable assignments and the variable itself
Remove unnecessary variable assignments, the variable itself and refactor the code. Addresses-Coverity-ID: 1227034 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/ipr.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index b0c68d2..633db65 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -8414,7 +8414,6 @@ static int ipr_reset_next_stage(struct ipr_cmnd *ipr_cmd) static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) { struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; - volatile u32 int_reg; volatile u64 maskval; int i; @@ -8431,15 +8430,14 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) if (ioa_cfg->sis64) { /* Set the adapter to the correct endian mode. */ writel(IPR_ENDIAN_SWAP_KEY, ioa_cfg->regs.endian_swap_reg); - int_reg = readl(ioa_cfg->regs.endian_swap_reg); + readl(ioa_cfg->regs.endian_swap_reg); } - int_reg = readl(ioa_cfg->regs.sense_interrupt_reg32); - - if (int_reg & IPR_PCII_IOA_TRANS_TO_OPER) { + if (readl(ioa_cfg->regs.sense_interrupt_reg32) & + IPR_PCII_IOA_TRANS_TO_OPER) { writel((IPR_PCII_ERROR_INTERRUPTS | IPR_PCII_HRRQ_UPDATED), ioa_cfg->regs.clr_interrupt_mask_reg32); - int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); + readl(ioa_cfg->regs.sense_interrupt_mask_reg); return IPR_RC_JOB_CONTINUE; } @@ -8453,7 +8451,7 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd) } else writel(IPR_PCII_OPER_INTERRUPTS, ioa_cfg->regs.clr_interrupt_mask_reg32); - int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); + readl(ioa_cfg->regs.sense_interrupt_mask_reg); dev_info(_cfg->pdev->dev, "Initializing IOA.\n"); -- 2.5.0
[PATCH] scsi: remove useless variable assignment
Remove both variable assignments once the value stored in variable _reqlen_ is overwritten at some point either by line 2321: reqlen = mptr - msg; or by line 2330: reqlen = 12; Addresses-Coverity-ID: 1226930 Addresses-Coverity-ID: 1226931 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/dpt_i2o.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 256dd67..acad668 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -2292,11 +2292,8 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d mptr+=4; lenptr=mptr++; /* Remember me - fill in when we know */ if (dpt_dma64(pHba)) { - reqlen = 16;// SINGLE SGE *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ *mptr++ = 1 << PAGE_SHIFT; - } else { - reqlen = 14;// SINGLE SGE } /* Now fill in the SGList and command */ -- 2.5.0 --- Begin Message --- Remove both variable assignments once the value stored in variable _reqlen_ is overwritten at some point either by line 2321: reqlen = mptr - msg; or by line 2330: reqlen = 12; Addresses-Coverity-ID: 1226930 Addresses-Coverity-ID: 1226931 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/dpt_i2o.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 256dd67..acad668 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -2292,11 +2292,8 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d mptr+=4; lenptr=mptr++; /* Remember me - fill in when we know */ if (dpt_dma64(pHba)) { - reqlen = 16;// SINGLE SGE *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ *mptr++ = 1 << PAGE_SHIFT; - } else { - reqlen = 14;// SINGLE SGE } /* Now fill in the SGList and command */ -- 2.5.0 --- End Message ---
[PATCH] scsi: lpfc: prevent potential null pointer dereference
Null check at line 966: if (ndlp) {, implies that ndlp might be NULL. Functions lpfc_nlp_set_state() and lpfc_issue_els_prli() dereference pointer ndlp. Include these function calls inside the IF block that tests pointer ndlp. Addresses-Coverity-ID: 1401856 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/lpfc/lpfc_ct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index c7962da..ecb174b 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -978,9 +978,10 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp, did, ndlp->nlp_fc4_type, FC_TYPE_FCP, FC_TYPE_NVME); ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; + + lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); + lpfc_issue_els_prli(vport, ndlp, 0); } - lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); - lpfc_issue_els_prli(vport, ndlp, 0); } else lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, "3065 GFT_ID failed x%08x\n", irsp->ulpStatus); -- 2.5.0
[PATCH] scsi: hisi_sas: add null check before indirect pointer dereference
Add null check before indirectly dereferencing pointer task->lldd_task in statement u32 tag = slot->idx; Addresses-Coverity-ID: 1373843 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index d622db5..f720d3c 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -963,7 +963,7 @@ static int hisi_sas_abort_task(struct sas_task *task) HISI_SAS_INT_ABT_DEV, 0); rc = hisi_sas_softreset_ata_disk(device); } - } else if (task->task_proto & SAS_PROTOCOL_SMP) { + } else if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SMP) { /* SMP */ struct hisi_sas_slot *slot = task->lldd_task; u32 tag = slot->idx; -- 2.5.0
[PATCH] scsi: cxgbi: add null check before pointer dereference
Add null check before dereferencing pointer _sg_ inside sg_next() Addresses-Coverity-ID: 1364845 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/cxgbi/libcxgbi.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index bd7d39e..6119ddf 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -1256,15 +1256,18 @@ void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod, *sg_off = offset; } - if (offset == len) { - offset = 0; - sg = sg_next(sg); - if (sg) { - addr = sg_dma_address(sg); - len = sg_dma_len(sg); + if (sg) { + if (offset == len) { + offset = 0; + sg = sg_next(sg); + if (sg) { + addr = sg_dma_address(sg); + len = sg_dma_len(sg); + } } - } - ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL; + ppod->addr[i] = cpu_to_be64(addr + offset); + } else + ppod->addr[i] = 0ULL; } EXPORT_SYMBOL_GPL(cxgbi_ddp_set_one_ppod); -- 2.5.0
Re: [PATCH] scsi: remove useless variable assignment
Hi James, Quoting James Bottomley <j...@linux.vnet.ibm.com>: On Wed, 2017-05-17 at 19:30 -0500, Gustavo A. R. Silva wrote: Remove this assignment once the value stored in variable _k_ is overwritten after a few lines. Addresses-Coverity-ID: 1226927 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/qlogicfas408.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index c3a9151..269440a 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -329,7 +329,6 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) */ if ((k = ql_wai(priv))) return (k << 16); - k = inb(qbase + 5); /* should be 0x10, bus service */ That doesn't look right to me. inb() is a statement which has an effect on the I/O device regardless of whether the returned value is used or discarded. In this case I think it's being used to clear pending interrupts, so removing it will likely cause a phase error. You are right, I get it. In this case I think a patch to ignore the return value could be applied: index c3a9151..8f5339a 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -329,7 +329,7 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) */ if ((k = ql_wai(priv))) return (k << 16); - k = inb(qbase + 5); /* should be 0x10, bus service */ + inb(qbase + 5); /* should be 0x10, bus service */ } What do you think? Thank you for the clarification. -- Gustavo A. R. Silva
[PATCH] scsi: remove useless variable assignment
Remove both variable assignments once the value stored in variable _reqlen_ is overwritten at some point either by line 2321: reqlen = mptr - msg; or by line 2330: reqlen = 12; Addresses-Coverity-ID: 1226930 Addresses-Coverity-ID: 1226931 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/dpt_i2o.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 256dd67..acad668 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -2292,11 +2292,8 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d mptr+=4; lenptr=mptr++; /* Remember me - fill in when we know */ if (dpt_dma64(pHba)) { - reqlen = 16;// SINGLE SGE *mptr++ = (0x7C<<24)+(2<<16)+0x02; /* Enable 64 bit */ *mptr++ = 1 << PAGE_SHIFT; - } else { - reqlen = 14;// SINGLE SGE } /* Now fill in the SGList and command */ -- 2.5.0
[PATCH] scsi: remove useless variable assignment
Remove this assignment once the value stored in variable _k_ is overwritten after a few lines. Addresses-Coverity-ID: 1226927 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/qlogicfas408.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index c3a9151..269440a 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -329,7 +329,6 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) */ if ((k = ql_wai(priv))) return (k << 16); - k = inb(qbase + 5); /* should be 0x10, bus service */ } /* -- 2.5.0
[PATCH] scsi: libfc: fix incorrect variable assingment
Previous assignment was causing the use of the uninitialized variable _explan_ inside fc_seq_ls_rjt() function, which in this particular case is being called by fc_seq_els_rsp_send(). Addresses-Coverity-ID: 1398125 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/libfc/fc_rport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index b44c313..5203258 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -1422,7 +1422,7 @@ static void fc_rport_recv_rtv_req(struct fc_rport_priv *rdata, fp = fc_frame_alloc(lport, sizeof(*rtv)); if (!fp) { rjt_data.reason = ELS_RJT_UNAB; - rjt_data.reason = ELS_EXPL_INSUF_RES; + rjt_data.explan = ELS_EXPL_INSUF_RES; fc_seq_els_rsp_send(in_fp, ELS_LS_RJT, _data); goto drop; } -- 2.5.0
[PATCH] target: remove dead code
Local variable _ret_ is assigned to a constant value and it is never updated again. Remove this variable and the dead code it guards. Addresses-Coverity-ID: 140761 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/target/target_core_rd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index ddc216c..6e8ef23 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -568,7 +568,7 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, struct rd_dev *rd_dev = RD_DEV(dev); char *orig, *ptr, *opts; substring_t args[MAX_OPT_ARGS]; - int ret = 0, arg, token; + int arg, token; opts = kstrdup(page, GFP_KERNEL); if (!opts) @@ -603,7 +603,7 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, } kfree(orig); - return (!ret) ? count : ret; + return count; } static ssize_t rd_show_configfs_dev_params(struct se_device *dev, char *b) -- 2.5.0
[PATCH] scsi: qla2xxx: remove dead code
Local variable page_mode is assigned to a constant value and it is never updated again. Remove this variable and the dead code it guards. Addresses-Coverity-ID: 200420 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/qla2xxx/qla_nx.c | 48 --- 1 file changed, 48 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 0a1723c..bff63b2 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -2676,26 +2676,9 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, int ret; uint32_t liter; uint32_t rest_addr; - dma_addr_t optrom_dma; - void *optrom = NULL; - int page_mode = 0; struct qla_hw_data *ha = vha->hw; ret = -1; - - /* Prepare burst-capable write on supported ISPs. */ - if (page_mode && !(faddr & 0xfff) && - dwords > OPTROM_BURST_DWORDS) { - optrom = dma_alloc_coherent(>pdev->dev, OPTROM_BURST_SIZE, - _dma, GFP_KERNEL); - if (!optrom) { - ql_log(ql_log_warn, vha, 0xb01b, - "Unable to allocate memory " - "for optrom burst write (%x KB).\n", - OPTROM_BURST_SIZE / 1024); - } - } - rest_addr = ha->fdt_block_size - 1; ret = qla82xx_unprotect_flash(ha); @@ -2718,34 +2701,6 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, } } - /* Go with burst-write. */ - if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { - /* Copy data to DMA'ble buffer. */ - memcpy(optrom, dwptr, OPTROM_BURST_SIZE); - - ret = qla2x00_load_ram(vha, optrom_dma, - (ha->flash_data_off | faddr), - OPTROM_BURST_DWORDS); - if (ret != QLA_SUCCESS) { - ql_log(ql_log_warn, vha, 0xb01e, - "Unable to burst-write optrom segment " - "(%x/%x/%llx).\n", ret, - (ha->flash_data_off | faddr), - (unsigned long long)optrom_dma); - ql_log(ql_log_warn, vha, 0xb01f, - "Reverting to slow-write.\n"); - - dma_free_coherent(>pdev->dev, - OPTROM_BURST_SIZE, optrom, optrom_dma); - optrom = NULL; - } else { - liter += OPTROM_BURST_DWORDS - 1; - faddr += OPTROM_BURST_DWORDS - 1; - dwptr += OPTROM_BURST_DWORDS - 1; - continue; - } - } - ret = qla82xx_write_flash_dword(ha, faddr, cpu_to_le32(*dwptr)); if (ret) { @@ -2761,9 +2716,6 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, ql_log(ql_log_warn, vha, 0xb021, "Unable to protect flash after update.\n"); write_done: - if (optrom) - dma_free_coherent(>pdev->dev, - OPTROM_BURST_SIZE, optrom, optrom_dma); return ret; } -- 2.5.0
Re: [PATCH] scsi: qedf: properly update arguments position in function call
Hi Martin, Quoting "Martin K. Petersen" <martin.peter...@oracle.com>: Gustavo A., Properly update the position of the arguments in function call. Applied to 4.12/scsi-fixes, thank you! Awesome, glad to help. :) -- Gustavo A. R. Silva
[PATCH] scsi: qedf: properly update arguments position in function call
Properly update the position of the arguments in function call. Addresses-Coverity-ID: 1402010 Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/scsi/qedf/qedf_els.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c index 59f3e5c..107ed2b 100644 --- a/drivers/scsi/qedf/qedf_els.c +++ b/drivers/scsi/qedf/qedf_els.c @@ -106,7 +106,7 @@ static int qedf_initiate_els(struct qedf_rport *fcport, unsigned int op, did = fcport->rdata->ids.port_id; sid = fcport->sid; - __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, sid, did, + __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, did, sid, FC_TYPE_ELS, FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); -- 2.5.0
Re: [scsi-qedf] question about parameter ordering
Hi Chad, Quoting Chad Dupuis <chad.dup...@cavium.com>: On Wed, 3 May 2017, 1:58pm, Gustavo A. R. Silva wrote: Hello everybody, While looking into Coverity ID 1402011 I ran into the following piece of code at drivers/scsi/qedf/qedf_io.c:2057: /* Fill FC header */ fc_hdr = &(tm_req->req_fc_hdr); sid = fcport->sid; did = fcport->rdata->ids.port_id; __fc_fill_fc_hdr(fc_hdr, FC_RCTL_DD_UNSOL_CMD, sid, did, FC_TYPE_FCP, FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); The issue here is that the position of arguments in the call to __fc_fill_fc_hdr() function do not match the ordering of the parameters: _sid_ is passed to _did_ _did_ is passed to _sid_ this is the function prototype: static inline void __fc_fill_fc_hdr(struct fc_frame_header *fh, enum fc_rctl r_ctl, u32 did, u32 sid, enum fc_fh_type type, u32 f_ctl, u32 parm_offset) My question here is if this is intentionala? This may have been but this code has been superseded by commit be086e7c53f1fac51eed14523b28f2214b548dd2.B Oh OK, great. In case it is not, I will send a patch to fix it. But first it would be great to hear any comment about it. By the way... the same is happening at drivers/scsi/qedf/qedf_els.c:109 May be a bug here so you could send a patch. I'll send a patch for this shortly. Thanks for your comments. -- Gustavo A. R. Silva
[scsi-qedf] question about parameter ordering
Hello everybody, While looking into Coverity ID 1402011 I ran into the following piece of code at drivers/scsi/qedf/qedf_io.c:2057: /* Fill FC header */ fc_hdr = &(tm_req->req_fc_hdr); sid = fcport->sid; did = fcport->rdata->ids.port_id; __fc_fill_fc_hdr(fc_hdr, FC_RCTL_DD_UNSOL_CMD, sid, did, FC_TYPE_FCP, FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); The issue here is that the position of arguments in the call to __fc_fill_fc_hdr() function do not match the ordering of the parameters: _sid_ is passed to _did_ _did_ is passed to _sid_ this is the function prototype: static inline void __fc_fill_fc_hdr(struct fc_frame_header *fh, enum fc_rctl r_ctl, u32 did, u32 sid, enum fc_fh_type type, u32 f_ctl, u32 parm_offset) My question here is if this is intentional? In case it is not, I will send a patch to fix it. But first it would be great to hear any comment about it. By the way... the same is happening at drivers/scsi/qedf/qedf_els.c:109 Thank you -- Gustavo A. R. Silva
Re: [PATCH] drivers: block: Remove unnecessary cast
Quoting Greg KH <gre...@linuxfoundation.org>: On Wed, Jan 11, 2017 at 12:41:05PM -0600, Gustavo A. R. Silva wrote: This issue was detected using Coccinelle and the following semantic patch: @@ expression * e; expression arg1, arg2; type T; @@ - e = (T *) + e = kmalloc(arg1, arg2); Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/block/cciss_scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Why send this to me? Oops... Sorry... I was also working with the Staging tree, so it seems your e-mail address got in the middle at some point. -- Gustavo A. R. Silva -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] drivers: block: Remove unnecessary cast
This issue was detected using Coccinelle and the following semantic patch: @@ expression * e; expression arg1, arg2; type T; @@ - e = (T *) + e = kmalloc(arg1, arg2); Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com> --- drivers/block/cciss_scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index a18de9d..98ba8fc 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -647,8 +647,7 @@ cciss_scsi_setup(ctlr_info_t *h) struct cciss_scsi_adapter_data_t * shba; ccissscsi[h->ctlr].ndevices = 0; - shba = (struct cciss_scsi_adapter_data_t *) - kmalloc(sizeof(*shba), GFP_KERNEL); + shba = kmalloc(sizeof(*shba), GFP_KERNEL); if (shba == NULL) return; shba->scsi_host = NULL; -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html