Skip to content

Commit 175086c

Browse files
Yan Zhenmiquelraynal
authored andcommitted
mtd: concat: Use kmemdup_array instead of kmemdup for multiple allocation
When we are allocating an array, using kmemdup_array() to take care about multiplication and possible overflows. Also it makes auditing the code easier. Signed-off-by: Yan Zhen <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent e334c01 commit 175086c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/mtd/mtdconcat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,
204204
}
205205

206206
/* make a copy of vecs */
207-
vecs_copy = kmemdup(vecs, sizeof(struct kvec) * count, GFP_KERNEL);
207+
vecs_copy = kmemdup_array(vecs, count, sizeof(struct kvec), GFP_KERNEL);
208208
if (!vecs_copy)
209209
return -ENOMEM;
210210

0 commit comments

Comments
 (0)