Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619504

[PATCH 1/3] iscsi-target: Use kcalloc() in iscsit_allocate_iovecs()

Path csiph.com!1.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/3] iscsi-target: Use kcalloc() in iscsit_allocate_iovecs()
Date Sun, 09 Apr 2017 16:30:01 +0200
Message-ID <tum0N-3WS-9@gated-at.bofh.it> (permalink)
References <tum0N-3WS-3@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Language en-GB
Content-Transfer-Encoding 7bit
X-Provags-ID V03:K0:y8+fZKgqvC4crxF54Qz6X1pwbu5fRAgFyEX432/Z2pOUkhTJ7Y8 qA/ugQHGnbfa3TWhf6EH+uC90x0GnHjnOinmRXEcLnC6VnAMzZERlZglMIcPVXpDCzX0Xy0 HBurwNBlty5WXy5gCudiAm3YRm4sMru0sC2Z+0uYPSJInfz/Yuuk60zj6uMzzgq92r9LCvZ B8b8LE0MQklSLIUMloRgQ==
X-Ui-Out-Filterresults notjunk:1;V01:K0:Ih43/fpko/o=:3ojeU2Ae3GWlSOzFSsDoWN DNSA+nB43DIKU5ZkLYVzqLyYrPUwDeh7gwM6HNagxL8l368laRQ82QYTdvY48ttKTWusP3vj2 SrXWn11znnZvskgjivfBdppwk8k/MlB3gsrFXGMRMBw/lyGp/lGdT2dflYxbK73S/BDxYczNv +LqUbY1tr8G54Qc7dIouAakFLUc7I/PpPhBkXx6lWbltICIPcbPTbq9lVl5SMKB8iRns9BAuO hl2OlOx/M9jSjCpwDWHIuLXKzS5C2OquoLb4smtw3hhPi5WodaT7U5pAbPrJuBlE0wO8XEfJ7 4SsPoNhN48KLM7ydp25biW7twskkqTyMUuR/PgLfFiXddaJ8Q7Ah632RIW9rk7BLk0vOxY8Jj 7I0RasF2NAwikdFuiZVU/6+jswvl8i2abNglghhYl+c7NbGkA8TC+P65oGUWTHp5vvZ0sgHyn Mpxj/kve/6ARaznw00YI3lbyeXr5XBfqbGyreyeALIvLc7stmpZO2Aqf2SkjJsLh2taKGGSkZ PiEsuaYpQ+E1mboa/fiBy014x95HHPFd9TezJ0CeiGnvgWYMihxwzl8/n2Y3xBKzjZQFrCayD 4Csbo/oNrnyaEbftihGeaF2wtkCy/Ez436MtXpAidyNgznTKYoKK0DeYm3o2CFvRMJCoLeHfl OlRjWOG8FVfhQYzZdrplQUAjm5sK/IrePTM5R/ywFWCZu5wW6lFuYxrxYZzH/pltX77y4ol+/ Mp9ZBFRvCCfXFEABR7FMOfbLt/ROgz6KB/SGg+FRbVEGPfkpn/8J0HRiKx1YwmtmaAWpjAaCK 2ANvZpe
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 34
Organization linux.* mail to news gateway
X-Original-Cc LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
X-Original-Date Sun, 9 Apr 2017 16:23:41 +0200
X-Original-Message-ID <ba9505d9-9c00-9534-c16b-4fab5403a57e@users.sourceforge.net>
X-Original-References <f573fbbe-aef2-7b68-1540-ceb2f30a6aa6@users.sourceforge.net>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1619504

Show key headers only | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 9 Apr 2017 15:06:00 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index a91802432f2f..536b939afe9d 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -985,8 +985,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
 	u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE));
 
 	iov_count += ISCSI_IOV_DATA_BUFFER;
-
-	cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL);
+	cmd->iov_data = kcalloc(iov_count, sizeof(*cmd->iov_data), GFP_KERNEL);
 	if (!cmd->iov_data) {
 		pr_err("Unable to allocate cmd->iov_data\n");
 		return -ENOMEM;
-- 
2.12.2

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/3] iscsi-target: Use kcalloc() in iscsit_allocate_iovecs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-09 16:30 +0200

csiph-web