[PATCH] btrfs:check-integrity.c: replace kmalloc with kmalloc_array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

Signed-off-by: Himangi Saraogi <himangi774@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux