All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Qu Wenruo <wqu@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] btrfs: scrub: use safer allocation function in init_scrub_stripe()
Date: Thu, 6 Apr 2023 11:56:44 +0300	[thread overview]
Message-ID: <3174f3bc-f83f-4009-b062-45eadb5c73d6@kili.mountain> (raw)

It's just always better to use kcalloc() instead of open coding the
size calculation.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 fs/btrfs/scrub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index ccb4f58ae307..6afb0abc83ce 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -254,7 +254,7 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
 	if (!stripe->sectors)
 		goto error;
 
-	stripe->csums = kzalloc((BTRFS_STRIPE_LEN >> fs_info->sectorsize_bits) *
+	stripe->csums = kcalloc((BTRFS_STRIPE_LEN >> fs_info->sectorsize_bits),
 				fs_info->csum_size, GFP_KERNEL);
 	if (!stripe->csums)
 		goto error;
-- 
2.39.1


             reply	other threads:[~2023-04-06  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  8:56 Dan Carpenter [this message]
2023-04-06  9:10 ` [PATCH] btrfs: scrub: use safer allocation function in init_scrub_stripe() Qu Wenruo
2023-04-06 14:37 ` David Sterba
2023-04-06 15:13 ` Christoph Hellwig
2023-04-06 16:06   ` David Sterba

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=3174f3bc-f83f-4009-b062-45eadb5c73d6@kili.mountain \
    --to=error27@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.