From: Yan Zhen Date: Fri, 23 Aug 2024 11:08:24 +0000 (+0800) Subject: mtd: concat: Use kmemdup_array instead of kmemdup for multiple allocation X-Git-Tag: v6.12-rc1~159^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=175086cf4acdf4ccd3d7a6bb5c5231ececd6656b;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20240823110824.3895787-1-yanzhen@vivo.com --- diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 193428de6a4bd..f56f44aa8625c 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -204,7 +204,7 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, } /* make a copy of vecs */ - vecs_copy = kmemdup(vecs, sizeof(struct kvec) * count, GFP_KERNEL); + vecs_copy = kmemdup_array(vecs, count, sizeof(struct kvec), GFP_KERNEL); if (!vecs_copy) return -ENOMEM;