Kernel-Janitors Archive on lore.kernel.org
 help / color / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Hannes Reinecke <hare@suse.com>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	Varun Prakash <varun@chelsio.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3] iscsi-target: Use kcalloc() in iscsit_allocate_iovecs()
Date: Sun, 09 Apr 2017 14:23:41 +0000
Message-ID: <ba9505d9-9c00-9534-c16b-4fab5403a57e@users.sourceforge.net> (raw)
In-Reply-To: <f573fbbe-aef2-7b68-1540-ceb2f30a6aa6@users.sourceforge.net>

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


       reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f573fbbe-aef2-7b68-1540-ceb2f30a6aa6@users.sourceforge.net>
2017-04-09 14:23 ` SF Markus Elfring [this message]
2017-04-09 14:26 ` [PATCH 2/3] iscsi-target: Delete error messages for failed memory allocations SF Markus Elfring
2017-04-09 14:28 ` [PATCH 3/3] iscsi-target: Improve size determinations in four functions SF Markus Elfring

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=ba9505d9-9c00-9534-c16b-4fab5403a57e@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=bart.vanassche@sandisk.com \
    --cc=hare@suse.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    --cc=varun@chelsio.com \
    /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

Kernel-Janitors Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernel-janitors/0 kernel-janitors/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernel-janitors kernel-janitors/ https://lore.kernel.org/kernel-janitors \
		kernel-janitors@vger.kernel.org
	public-inbox-index kernel-janitors

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kernel-janitors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git