Received: by 10.223.185.116 with SMTP id b49csp2332461wrg; Mon, 5 Mar 2018 00:35:07 -0800 (PST) X-Google-Smtp-Source: AG47ELt1aU1dSSHWXZWmDdwTj5pdINufRr4VNRUYl2iuPdROGa7k+zRNfQH1H6GidDlVrODOMKYO X-Received: by 2002:a17:902:7045:: with SMTP id h5-v6mr12554822plt.217.1520238907352; Mon, 05 Mar 2018 00:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520238907; cv=none; d=google.com; s=arc-20160816; b=BMUa1UIBWGbgj5mX7bnMm4mSrnZ+FNUv4YjgFmB8BtHdgdwpankLDcyiU8bi1HX8EY /J4XelHx/lagndYRRjQ12ebngE4olqsT6HMDXrGW27dWb9fhvxMgXvg2NOSJ5Y8DmjZ3 P2xwNBvxA1Sb+u80X13QsebHWL6ikWib1mTdXyuoJMbvPQm399qq1T0WJj0IJJw1lPMs omhARQKD9l8BIlWSQ9zggEJapZdRRCOqvM4BgHQQ76yj/n6b8cZB1g8o/O1He0PzrEzs M7G3yi9vbd6mb7YGSX/ns7vXbgfkohlb6BQAwnJYQTeZp8CVxN3HxWQaToolw/3gQTzp KmXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=FqDmAHD5zOGUl8juamdnCt8q1fE/iiVHoJ/dqsYtu18=; b=ZVSACFCcusUnMdUwMXl04HEYGMiqdR1iFitQjU319mhezq8QTUA40Y/tqvKWOl/efy dCjzIURFmL5Emggui+7yd+v43RXLqKQ6k5erPGvXttJXGlyzeFmNiToxLukgtra7xU6U JItHRQA39bTqijtuIfIYr6ZIAmHP9BR+KnVoGFDzkNJd4prZQuJJ0Md8+V+XIFxcXvSX q3y11PlquNGB2BYxtgQyrGPPa10/xBvP5FaGmMhfBqWzgcQOXlsQcefoIBNH9hzeJX0m YEafuV/p4uVieN6kJduPY0HlNWaTcHuX1iSIu4qdkiOGQAdHeWEOrTbElOM8VLertyIR mGLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c15-v6si8921486plz.630.2018.03.05.00.34.53; Mon, 05 Mar 2018 00:35:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752566AbeCEIcp (ORCPT + 99 others); Mon, 5 Mar 2018 03:32:45 -0500 Received: from mout.web.de ([217.72.192.78]:51081 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbeCEIcn (ORCPT ); Mon, 5 Mar 2018 03:32:43 -0500 Received: from [192.168.1.2] ([92.228.188.109]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LaTeV-1ePWwC3JMd-00mGdo; Mon, 05 Mar 2018 09:32:31 +0100 Subject: [PATCH 2/4] scsi: hpsa: Less function calls in hpsa_big_passthru_ioctl() after error detection From: SF Markus Elfring To: linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com, Don Brace , "James E. J. Bottomley" , "Martin K. Petersen" Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Mon, 5 Mar 2018 09:32:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:Y/lM97Sz93C0ANeqOcHlDzh4o8RZGt3sdlgvkll2rnXEkwO94xH eVjax4TUviRVSAlOK5HibGFRM6qYZoQMudMVLVbW90PRd3iwuXEEN0LT3rNNK1Hk6r2gLc6 Hitx84Zs8yHKHtsGQg6KTqNC9EYxSU15sEhgCx+SXaHNasnR4eDR/qmalAkPZPJ9v/9qB0/ 4n0w3mslJB4sZNcjA/jpQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:M8JT4hgY4z0=:7BqNJNCT3BCTf3Ku4NWiy6 aWTe92ItB/kgbFZqfHgFRYAgl4wIcVn7IRhkXE1CtG3rlDwNl87ZU9PvawnQfbwMXs0n+HTgs BF19y4IuZP56Fw8jfX6Oy2mkxYFhgrzozEoc711Q9nkn89jfBlC6zVntdz5NRNO0HkuUOk2CS r5zqSEryebhVe+SbypnB2p0bmQihMLUdHz4w8t5Y9wGNQ8pfhE9D+ZIW23xhv4F3H7ylGvltE iKJaJoIXkBH/E+T1Au07jOwrZvOSYM15CT466TWj6pl3k352LRQc4e+/ur9iWl6WUqdKM9+Wv 2w+e0bsziqOVYY46weLRCRPqrfkmbSZ9e7JhDCNrUn7JytuH5PX9zbJW3doNGV4HU6ImGhu2v IiANp04T2nAZ+qHcHQ1C35hwt+r0s+Dr9TLH+SPr5VBET93+0lCCZNfQTeKhXd0kPSco+SiX4 nDaNk0vonJazbD/EBmOJK4yXheHitrwq3pglmEc5EtQqKh5Cf2yKB5SpXcFCvo1cK5qdqleEM dvc/6D9QBmVoOe+Jx3eVSKxZXfhU3BzBwhwInQBzFodvNjQdTABbI1c6O0w5C0I+7BGpDnZzJ E2ib0zoEo5IBnXAcazdBgftIqvnlk+mxZBLIty13YW0wTeZDwYsfLh0nVAQWNwsLw5olQvC77 AnCNglJj2nF9f5yXPVMtz8zkWQiP4VRRdQWoFlRX+SvF58Y+wnAlVWzlZaq9UW/3yS1z85/+i xDq5LYyYGDZ0sYbXj6VJ7uUn4E1mvDiuL0RNpDC0yGlK+qEvyLmDwsflQ2+031MX5rT+y/SxS wbDSfaYWKSkCrUg77po+S81SmJNF4Om4NcGEfgWbe9CAPSRaYU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 4 Mar 2018 22:00:19 +0100 The function "kfree" was called in a few cases by the hpsa_big_passthru_ioctl() function during error handling even if the passed variable contained a null pointer. * Adjust jump targets. * Delete two initialisations and a check (for the local variable "buff") which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/scsi/hpsa.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index b35248becef9..45177ead811f 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -6377,8 +6377,8 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) { BIG_IOCTL_Command_struct *ioc; struct CommandList *c; - unsigned char **buff = NULL; - int *buff_size = NULL; + unsigned char **buff; + int *buff_size; u64 temp64; BYTE sg_used = 0; int status = 0; @@ -6397,26 +6397,26 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) if ((ioc->buf_size < 1) && (ioc->Request.Type.Direction != XFER_NONE)) { status = -EINVAL; - goto cleanup1; + goto free_ioc; } /* Check kmalloc limits using all SGs */ if (ioc->malloc_size > MAX_KMALLOC_SIZE) { status = -EINVAL; - goto cleanup1; + goto free_ioc; } if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD) { status = -EINVAL; - goto cleanup1; - } - buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL); - if (!buff) { - status = -ENOMEM; - goto cleanup1; + goto free_ioc; } buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL); if (!buff_size) { status = -ENOMEM; - goto cleanup1; + goto free_ioc; + } + buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL); + if (!buff) { + status = -ENOMEM; + goto free_buff_size; } left = ioc->buf_size; data_ptr = ioc->buf; @@ -6501,14 +6501,16 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) cleanup0: cmd_free(h, c); cleanup1: - if (buff) { + { int i; for (i = 0; i < sg_used; i++) kfree(buff[i]); kfree(buff); } +free_buff_size: kfree(buff_size); +free_ioc: kfree(ioc); return status; } -- 2.16.2