public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Martin Brandenburg <martin@omnibond.com>,
	Mike Marshall <hubcap@omnibond.com>,
	kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] orangefs: Use kcalloc() in orangefs_prepare_cdm_array()
Date: Thu, 17 Aug 2017 22:14:39 +0200	[thread overview]
Message-ID: <705dd4fa-3daf-08fb-23c8-1888b67bc1ce@users.sourceforge.net> (raw)
In-Reply-To: <6802994a-a537-2e00-e7d8-c1b822879f76@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 17 Aug 2017 21:18:01 +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>
---
 fs/orangefs/orangefs-debugfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 93fe8f8e60f1..5f59917fd631 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -571,7 +571,5 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
 		goto out;
 	}
 
-	cdm_array =
-		kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
-			GFP_KERNEL);
+	cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
 	if (!cdm_array) {
-- 
2.14.0

  parent reply	other threads:[~2017-08-17 20:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 20:11 [PATCH 0/3] OrangeFS: Adjustments for some function implementations SF Markus Elfring
2017-08-17 20:13 ` [PATCH 1/3] orangefs: Delete error messages for a failed memory allocation in five functions SF Markus Elfring
2017-08-17 20:14 ` SF Markus Elfring [this message]
2017-08-17 20:15 ` [PATCH 3/3] orangefs: Adjust three checks for null pointers 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=705dd4fa-3daf-08fb-23c8-1888b67bc1ce@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=hubcap@omnibond.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@omnibond.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox