From: Himangi Saraogi <himangi774@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs:check-integrity.c: replace kmalloc with kmalloc_array
Date: Fri, 1 Nov 2013 06:16:00 +0530 [thread overview]
Message-ID: <20131101004559.GA3258@himangi-Inspiron-N5110gmail.com> (raw)
This patch replaces kmalloc(size * nr, ) with kmalloc_array(nr, size)
as kmalloc_array() is preferred because it can check that the
calculation doesn't wrap and won't return a smaller allocation.
Reviewed-by: Zach Brown <zab@redhat.com>
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
fs/btrfs/check-integrity.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 1c47be1..d61ffef 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -3031,8 +3031,9 @@ void btrfsic_submit_bio(int rw, struct bio *bio)
(unsigned long long)bio->bi_sector, dev_bytenr,
bio->bi_bdev);
- mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt,
- GFP_NOFS);
+ mapped_datav = kmalloc_array(bio->bi_vcnt,
+ sizeof(*mapped_datav),
+ GFP_NOFS);
if (!mapped_datav)
goto leave;
for (i = 0; i < bio->bi_vcnt; i++) {
--
1.7.9.5
next reply other threads:[~2013-11-01 0:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 0:46 Himangi Saraogi [this message]
2013-11-06 17:37 ` [PATCH] btrfs:check-integrity.c: replace kmalloc with kmalloc_array 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=20131101004559.GA3258@himangi-Inspiron-N5110gmail.com \
--to=himangi774@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).