diff mbox series

[v1] mtd:concat:Switch to use kmemdup_array()

Message ID 20240823082535.3419187-1-yanzhen@vivo.com
State New
Headers show
Series [v1] mtd:concat:Switch to use kmemdup_array() | expand

Commit Message

Yan Zhen Aug. 23, 2024, 8:25 a.m. UTC
When we are allocating an array,
using kmemdup_array() is more appropriate 
and makes auditing the code easier.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 drivers/mtd/mtdconcat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Miquel Raynal Aug. 23, 2024, 8:39 a.m. UTC | #1
Hi Yan,

yanzhen@vivo.com wrote on Fri, 23 Aug 2024 16:25:35 +0800:

> When we are allocating an array,
> using kmemdup_array() is more appropriate 
> and makes auditing the code easier.

Why do you cap your lines at the insane limit of 40 chars?

Also you're missing spaces in the title after the ':'

s/Switch to use/Switch to/?

> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>  drivers/mtd/mtdconcat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> index 193428de6a4b..f56f44aa8625 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;
>  

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 193428de6a4b..f56f44aa8625 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;