lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54D53D47.7030102@users.sourceforge.net>
Date:	Fri, 06 Feb 2015 23:16:39 +0100
From:	SF Markus Elfring <elfring@...rs.sourceforge.net>
To:	"James E. J. Bottomley" <JBottomley@...allels.com>,
	QLogic-Storage-Upstream@...gic.com, linux-scsi@...r.kernel.org
CC:	LKML <linux-kernel@...r.kernel.org>,
	kernel-janitors@...r.kernel.org,
	Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH 3/4] SCSI-QLA4...: Less function calls in qla4xxx_is_flash_ddb_exists()
 after error detection

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 6 Feb 2015 21:55:55 +0100

The vfree() function was called in two cases by the
qla4xxx_is_flash_ddb_exists() function during error handling even if the passed
variables "fw_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.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/scsi/qla4xxx/ql4_os.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index a7ca479..e508bc9 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6470,16 +6470,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 				       struct dev_db_entry *fw_ddb_entry)
 {
 	struct qla_ddb_index  *nt_ddb_idx, *nt_ddb_idx_tmp;
-	struct ql4_tuple_ddb *fw_tddb = NULL;
-	struct ql4_tuple_ddb *tmp_tddb = NULL;
 	int rval, ret = QLA_ERROR;
+	struct ql4_tuple_ddb *tmp_tddb;
+	struct ql4_tuple_ddb *fw_tddb = vzalloc(sizeof(*fw_tddb));
 
-	fw_tddb = vzalloc(sizeof(*fw_tddb));
 	if (!fw_tddb) {
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
-		ret = QLA_SUCCESS;
-		goto exit_check;
+		return QLA_SUCCESS;
 	}
 
 	tmp_tddb = vzalloc(sizeof(*tmp_tddb));
@@ -6487,7 +6485,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 		DEBUG2(ql4_printk(KERN_WARNING, ha,
 				  "Memory Allocation failed.\n"));
 		ret = QLA_SUCCESS;
-		goto exit_check;
+		goto vfree_fw;
 	}
 
 	qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL);
@@ -6498,7 +6496,7 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 		ret = qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, true);
 		/* found duplicate ddb */
 		if (ret == QLA_SUCCESS)
-			goto exit_check;
+			goto vfree_tmp;
 	}
 
 	list_for_each_entry_safe(nt_ddb_idx, nt_ddb_idx_tmp, list_nt, list) {
@@ -6512,13 +6510,14 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 			else
 				ret = QLA_SUCCESS;
 
-			goto exit_check;
+			goto vfree_tmp;
 		}
 	}
 
-exit_check:
-	vfree(fw_tddb);
+vfree_tmp:
 	vfree(tmp_tddb);
+vfree_fw:
+	vfree(fw_tddb);
 	return ret;
 }
 
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ