From: SF Markus Elfring <elfring@users.sourceforge.net>
To: "James E. J. Bottomley" <JBottomley@parallels.com>,
QLogic-Storage-Upstream@qlogic.com, linux-scsi@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH 4/4] SCSI-QLA4...: Less function calls in qla4xxx_sysfs_ddb_logout() after error detection
Date: Fri, 06 Feb 2015 23:17:51 +0100 [thread overview]
Message-ID: <54D53D8F.7060307@users.sourceforge.net> (raw)
In-Reply-To: <54D53BE4.7010807@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Feb 2015 22:44:23 +0100
The vfree() function was called in three cases by the qla4xxx_sysfs_ddb_logout()
function during error handling even if the passed variables "flash_tddb" and
"tmp_tddb" contained still a null pointer.
* This implementation detail could be improved by adjustments for jump labels.
* Let us return immediately after the first failed function call according to
the current Linux coding style convention.
* Delete also an unnecessary check for the variable "fw_ddb_entry" there.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/scsi/qla4xxx/ql4_os.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index e508bc9..802390b 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -7699,23 +7699,22 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
- struct ql4_tuple_ddb *flash_tddb = NULL;
- struct ql4_tuple_ddb *tmp_tddb = NULL;
- struct dev_db_entry *fw_ddb_entry = NULL;
- struct ddb_entry *ddb_entry = NULL;
dma_addr_t fw_ddb_dma;
uint32_t next_idx = 0;
uint32_t state = 0, conn_err = 0;
uint16_t conn_id = 0;
int idx, index;
int status, ret = 0;
+ struct ql4_tuple_ddb *flash_tddb;
+ struct ql4_tuple_ddb *tmp_tddb;
+ struct ddb_entry *ddb_entry;
+ struct dev_db_entry *fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool,
+ GFP_KERNEL,
+ &fw_ddb_dma);
- fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL,
- &fw_ddb_dma);
- if (fw_ddb_entry == NULL) {
+ if (!fw_ddb_entry) {
ql4_printk(KERN_ERR, ha, "%s:Out of memory\n", __func__);
- ret = -ENOMEM;
- goto exit_ddb_logout;
+ return -ENOMEM;
}
flash_tddb = vzalloc(sizeof(*flash_tddb));
@@ -7723,7 +7722,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
ql4_printk(KERN_WARNING, ha,
"%s:Memory Allocation failed.\n", __func__);
ret = -ENOMEM;
- goto exit_ddb_logout;
+ goto free_pool;
}
tmp_tddb = vzalloc(sizeof(*tmp_tddb));
@@ -7731,7 +7730,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
ql4_printk(KERN_WARNING, ha,
"%s:Memory Allocation failed.\n", __func__);
ret = -ENOMEM;
- goto exit_ddb_logout;
+ goto free_flash;
}
if (!fnode_sess->targetname) {
@@ -7739,7 +7738,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
"%s:Cannot logout from SendTarget entry\n",
__func__);
ret = -EPERM;
- goto exit_ddb_logout;
+ goto free_tmp;
}
if (fnode_sess->is_boot_target) {
@@ -7747,7 +7746,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
"%s: Logout from boot target entry is not permitted.\n",
__func__);
ret = -EPERM;
- goto exit_ddb_logout;
+ goto free_tmp;
}
strlcpy(flash_tddb->iscsi_name, fnode_sess->targetname,
@@ -7794,12 +7793,12 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
if (idx == MAX_DDB_ENTRIES)
ret = -ESRCH;
-exit_ddb_logout:
- vfree(flash_tddb);
+free_tmp:
vfree(tmp_tddb);
- if (fw_ddb_entry)
- dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
-
+free_flash:
+ vfree(flash_tddb);
+free_pool:
+ dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
return ret;
}
--
2.2.2
next prev parent reply other threads:[~2015-02-06 22:17 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5307CAA2.8060406@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
[not found] ` <530A086E.8010901@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
[not found] ` <530A72AA.3000601@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
[not found] ` <530B5FB6.6010207@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
[not found] ` <530C5E18.1020800@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
[not found] ` <530CD2C4.4050903@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
[not found] ` <530CF8FF.8080600@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
[not found] ` <530DD06F.4090703@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
[not found] ` <5317A59D.4@users.sourceforge.net>
2014-10-22 18:55 ` [PATCH 1/1] SCSI-QLA2XXX: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-10-22 19:10 ` [PATCH 1/1] SCSI-QLA2...: " SF Markus Elfring
2014-11-20 17:23 ` [PATCH 1/1] SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk" SF Markus Elfring
2015-06-24 14:16 ` [PATCH] SCSI-OSD: Delete " SF Markus Elfring
2015-06-24 14:32 ` Johannes Thumshirn
2015-06-28 9:39 ` Boaz Harrosh
2014-11-20 17:55 ` [PATCH 1/1] SCSI: Deletion of unnecessary checks before the function call "put_device" SF Markus Elfring
2015-06-24 17:28 ` [PATCH] SCSI: Delete " SF Markus Elfring
2014-11-20 19:15 ` [PATCH 1/1] SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done" SF Markus Elfring
2015-06-24 15:54 ` [PATCH] SCSI-libfc: Delete " SF Markus Elfring
[not found] ` <558AD2D0.6000501-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-06-25 17:44 ` Vasu Dev
2014-11-20 19:42 ` [PATCH 1/1] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring
2015-06-30 12:52 ` [PATCH] " SF Markus Elfring
2014-11-20 22:23 ` [PATCH 1/1] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2015-06-30 12:50 ` [PATCH] " SF Markus Elfring
2014-11-20 22:46 ` [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-21 4:20 ` Anil Gurumurthy
2015-06-30 12:38 ` [PATCH] " SF Markus Elfring
2014-11-21 8:20 ` [PATCH 1/1] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release" SF Markus Elfring
2015-07-09 8:34 ` [PATCH] " SF Markus Elfring
2014-11-21 8:45 ` [PATCH 1/1] SCSI-fnic: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2015-06-24 18:45 ` [PATCH] SCSI-fnic: Delete " SF Markus Elfring
2014-11-21 9:30 ` [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put" SF Markus Elfring
2014-11-21 21:57 ` Nicholas A. Bellinger
2015-01-18 14:31 ` [PATCH 0/3] block: Deletion of checks before three function calls SF Markus Elfring
2015-01-18 14:37 ` [PATCH 1/3] block-cciss: Deletion of an unnecessary check before the function call "put_disk" SF Markus Elfring
2015-01-18 14:43 ` [PATCH 3/3] block: Deletion of checks before the function call "iounmap" SF Markus Elfring
2015-02-05 21:07 ` [PATCH] SCSI-bfa: Delete more unnecessary checks before the function call "vfree" SF Markus Elfring
2015-02-05 21:27 ` [PATCH] SCSI-aic7...: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
2015-07-09 8:22 ` SF Markus Elfring
2015-02-05 22:25 ` [PATCH 0/2] SCSI-lpfc: Deletion of an unnecessary check SF Markus Elfring
2015-02-05 22:26 ` [PATCH 1/2] SCSI-lpfc: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2015-02-05 22:28 ` [PATCH 2/2] SCSI-lpfc: One function call less in lpfc_bsg_hba_set_event() after error detection SF Markus Elfring
2015-02-16 15:58 ` [PATCH 0/2] SCSI-lpfc: Deletion of an unnecessary check James Smart
2015-02-06 17:20 ` [PATCH 0/3] SCSI-debug: Deletion of a few unnecessary checks SF Markus Elfring
2015-02-06 17:23 ` [PATCH 1/3] SCSI-debug: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2015-02-23 18:14 ` Douglas Gilbert
2015-02-06 17:25 ` [PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection SF Markus Elfring
2015-02-23 18:14 ` Douglas Gilbert
2015-02-06 17:26 ` [PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init() SF Markus Elfring
2015-02-23 18:15 ` Douglas Gilbert
2015-02-06 18:29 ` [PATCH] SCSI-csiostor: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
2015-02-06 22:10 ` [PATCH 0/4] SCSI-QLA4...: Deletion of some unnecessary checks SF Markus Elfring
2015-02-06 22:13 ` [PATCH 1/4] SCSI-QLA4...: Deletion of unnecessary checks before three function calls SF Markus Elfring
2015-02-06 22:15 ` [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection SF Markus Elfring
2015-02-07 9:33 ` Dan Carpenter
2015-02-07 10:11 ` Julia Lawall
2015-02-07 10:32 ` Dan Carpenter
2015-02-07 17:23 ` SF Markus Elfring
2015-02-06 22:16 ` [PATCH 3/4] SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists() " SF Markus Elfring
2015-02-06 22:17 ` SF Markus Elfring [this message]
2015-06-24 15:33 ` [PATCH] SCSI-wd33c93: Deletion of a check before the function call "wd33c93_setup" SF Markus Elfring
2015-06-25 9:55 ` Dan Carpenter
2015-11-16 8:45 ` [PATCH] SCSI-libfc: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
2015-11-19 18:21 ` Vasu Dev
2015-11-17 7:21 ` [PATCH] SCSI-aic94xx: Delete unnecessary checks " SF Markus Elfring
2016-07-24 11:51 ` SF Markus Elfring
2016-07-25 8:53 ` Jinpu Wang
2015-11-17 8:10 ` [PATCH] scsi_lib: Delete unnecessary checks before two function calls SF Markus Elfring
2015-11-17 8:44 ` [PATCH] SCSI-lpfc: Delete unnecessary checks before the function call "mempool_destroy" SF Markus Elfring
2015-12-16 23:17 ` James Smart
2016-07-16 20:20 ` [PATCH 0/3] xen-scsiback: Fine-tuning for scsiback_device_action() SF Markus Elfring
2016-07-16 20:22 ` [PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2016-07-18 5:01 ` Juergen Gross
2016-07-16 20:23 ` [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection SF Markus Elfring
2016-07-18 5:11 ` Juergen Gross
2016-07-19 14:56 ` SF Markus Elfring
2016-07-20 4:35 ` Juergen Gross
2016-07-20 5:10 ` SF Markus Elfring
2016-07-20 5:26 ` Juergen Gross
2016-07-20 11:27 ` [PATCH v2 0/3] xen-scsiback: Fine-tuning for scsiback_device_action() SF Markus Elfring
2016-07-20 11:30 ` [PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2016-07-20 11:44 ` Juergen Gross
2016-07-20 11:34 ` [PATCH v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action() SF Markus Elfring
2016-07-20 11:45 ` Juergen Gross
2016-07-20 11:36 ` [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant SF Markus Elfring
2016-07-20 11:44 ` Juergen Gross
2016-07-16 20:24 ` [PATCH " SF Markus Elfring
2016-07-18 5:05 ` Juergen Gross
2016-07-24 12:30 ` [PATCH] scsi: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2016-07-24 12:51 ` Laurence Oberman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54D53D8F.7060307@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=JBottomley@parallels.com \
--cc=QLogic-Storage-Upstream@qlogic.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).