From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758096AbbBFWPf (ORCPT ); Fri, 6 Feb 2015 17:15:35 -0500 Received: from mout.web.de ([212.227.17.11]:56226 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbbBFWPe (ORCPT ); Fri, 6 Feb 2015 17:15:34 -0500 Message-ID: <54D53CF1.8050009@users.sourceforge.net> Date: Fri, 06 Feb 2015 23:15:13 +0100 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "James E. J. Bottomley" , QLogic-Storage-Upstream@qlogic.com, linux-scsi@vger.kernel.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH 2/4] SCSI-QLA4...: Less function calls in qla4xxx_is_session_exists() after error detection References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <54D53BE4.7010807@users.sourceforge.net> In-Reply-To: <54D53BE4.7010807@users.sourceforge.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:+gkLHbFT3LC/WpGbYuScup5ierWPqURcScBRId0Acl1cITmsZLu zcwyKAG1MJHQBCCIBB0zIvcvdTkeyUek2G/w3oJ6mEACq25go4PE7eNxVG4TmH05n2fbY5U 3yyWXI9kX1zQfT8l3tUoi3MPS3hZG4NAZ4YsKs9zsL4AKTrMI7PijMSM2t7tQeSfjGjrops zIeViq3Hi1SbVxdlkJ6IA== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 6 Feb 2015 21:14:40 +0100 The vfree() function was called in two cases by the qla4xxx_is_session_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 --- drivers/scsi/qla4xxx/ql4_os.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 2a00fd3..a7ca479 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -6327,17 +6327,15 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, uint32_t *index) { struct ddb_entry *ddb_entry; - struct ql4_tuple_ddb *fw_tddb = NULL; - struct ql4_tuple_ddb *tmp_tddb = NULL; int idx; int 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)); @@ -6345,7 +6343,7 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, DEBUG2(ql4_printk(KERN_WARNING, ha, "Memory Allocation failed.\n")); ret = QLA_SUCCESS; - goto exit_check; + goto free_fw; } qla4xxx_convert_param_ddb(fw_ddb_entry, fw_tddb, NULL); @@ -6360,13 +6358,14 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, ret = QLA_SUCCESS; /* found */ if (index != NULL) *index = idx; - goto exit_check; + goto free_tmp; } } -exit_check: - vfree(fw_tddb); +free_tmp: vfree(tmp_tddb); +free_fw: + vfree(fw_tddb); return ret; } -- 2.2.2