summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDeepak R Varma <drv@mailo.com>2023-01-09 02:08:24 +0530
committerMartin K. Petersen <martin.petersen@oracle.com>2023-01-23 21:15:02 -0500
commit4fd62973739de61cf4c83b960db7d1824bd854a3 (patch)
tree416bc8985d5f886537cb674f9713cd4420e6abc1 /drivers
parent2aa0f83edb1c5a341f0aca209b0ecd74672fb3fa (diff)
downloadlinux-stable-4fd62973739de61cf4c83b960db7d1824bd854a3.tar.gz
linux-stable-4fd62973739de61cf4c83b960db7d1824bd854a3.tar.bz2
linux-stable-4fd62973739de61cf4c83b960db7d1824bd854a3.zip
scsi: qla2xxx: Use a variable for repeated mem_size computation
Use a variable to compute memory size to be allocated once instead of repeatedly computing it at different locations in the function. Issue identified using the array_size_dup Coccinelle semantic patch. Link: https://lore.kernel.org/r/Y7spwF8HTt0c0l7y@ubun2204.myguest.virtualbox.org Signed-off-by: Deepak R Varma <drv@mailo.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 8fa0056b56dd..8024322c9c5a 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1552,6 +1552,7 @@ static const struct qla_tgt_func_tmpl tcm_qla2xxx_template = {
static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport)
{
int rc;
+ size_t map_sz;
rc = btree_init32(&lport->lport_fcport_map);
if (rc) {
@@ -1559,17 +1560,15 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport)
return rc;
}
- lport->lport_loopid_map =
- vzalloc(array_size(65536,
- sizeof(struct tcm_qla2xxx_fc_loopid)));
+ map_sz = array_size(65536, sizeof(struct tcm_qla2xxx_fc_loopid));
+
+ lport->lport_loopid_map = vzalloc(map_sz);
if (!lport->lport_loopid_map) {
- pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n",
- sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
+ pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", map_sz);
btree_destroy32(&lport->lport_fcport_map);
return -ENOMEM;
}
- pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n",
- sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
+ pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n", map_sz);
return 0;
}