Message ID | 20131101004559.GA3258@himangi-Inspiron-N5110gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Nov 01, 2013 at 06:16:00AM +0530, Himangi Saraogi wrote: > 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. Can you please convert all the instances in one patch? Feel free to use the following cocinelle script, that found ~16 places that could use the conversion. $ cat kmalloc_array.cocci @ @ expression E1, E2, E3; @@ * \(kmalloc\|kzalloc\)(E1 * E2, E3) --- The output is not a straight patch, the instances have to be reviewed manually because the order of nritems and size may differ at each location. david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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++) {