mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc'
@ 2018-12-26  7:54 Christophe JAILLET
  2019-01-02 16:34 ` Anton Ivanov
  2019-01-08 23:58 ` Kees Cook
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2018-12-26  7:54 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, rppt, akpm, yuehaibing, keescook
  Cc: linux-um, linux-kernel, kernel-janitors, Christophe JAILLET

Use 'kmalloc_array' instead of 'kmalloc' when appropriate.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I don't know why it has not already been replaced in 6da2ec56059c
("treewide: kmalloc() -> kmalloc_array()".
---
 arch/um/drivers/vector_kern.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 5b917716289d..dee5246bda81 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -507,12 +507,12 @@ static struct vector_queue *create_queue(
 		return NULL;
 	result->max_depth = max_size;
 	result->dev = vp->dev;
-	result->mmsg_vector = kmalloc(
-		(sizeof(struct mmsghdr) * max_size), GFP_KERNEL);
+	result->mmsg_vector = kmalloc_array(max_size, sizeof(struct mmsghdr),
+					    GFP_KERNEL);
 	if (result->mmsg_vector == NULL)
 		goto out_mmsg_fail;
-	result->skbuff_vector = kmalloc(
-		(sizeof(void *) * max_size), GFP_KERNEL);
+	result->skbuff_vector = kmalloc_array(max_size, sizeof(void *),
+					      GFP_KERNEL);
 	if (result->skbuff_vector == NULL)
 		goto out_skb_fail;
 
-- 
2.19.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc'
  2018-12-26  7:54 [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc' Christophe JAILLET
@ 2019-01-02 16:34 ` Anton Ivanov
  2019-01-08 23:58 ` Kees Cook
  1 sibling, 0 replies; 3+ messages in thread
From: Anton Ivanov @ 2019-01-02 16:34 UTC (permalink / raw)
  To: Christophe JAILLET, jdike, richard, rppt, akpm, yuehaibing, keescook
  Cc: linux-um, linux-kernel, kernel-janitors



On 12/26/18 7:54 AM, Christophe JAILLET wrote:
> Use 'kmalloc_array' instead of 'kmalloc' when appropriate.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I don't know why it has not already been replaced in 6da2ec56059c
> ("treewide: kmalloc() -> kmalloc_array()".
> ---
>   arch/um/drivers/vector_kern.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 5b917716289d..dee5246bda81 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -507,12 +507,12 @@ static struct vector_queue *create_queue(
>   		return NULL;
>   	result->max_depth = max_size;
>   	result->dev = vp->dev;
> -	result->mmsg_vector = kmalloc(
> -		(sizeof(struct mmsghdr) * max_size), GFP_KERNEL);
> +	result->mmsg_vector = kmalloc_array(max_size, sizeof(struct mmsghdr),
> +					    GFP_KERNEL);
>   	if (result->mmsg_vector == NULL)
>   		goto out_mmsg_fail;
> -	result->skbuff_vector = kmalloc(
> -		(sizeof(void *) * max_size), GFP_KERNEL);
> +	result->skbuff_vector = kmalloc_array(max_size, sizeof(void *),
> +					      GFP_KERNEL);
>   	if (result->skbuff_vector == NULL)
>   		goto out_skb_fail;
>   
> 

Acked-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov

Cambridge Greys Limited, England and Wales company No 10273661
http://www.cambridgegreys.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc'
  2018-12-26  7:54 [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc' Christophe JAILLET
  2019-01-02 16:34 ` Anton Ivanov
@ 2019-01-08 23:58 ` Kees Cook
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2019-01-08 23:58 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Jeff Dike, Richard Weinberger, anton.ivanov, Mike Rapoport,
	Andrew Morton, YueHaibing, linux-um, LKML, kernel-janitors

On Fri, Dec 28, 2018 at 1:57 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Use 'kmalloc_array' instead of 'kmalloc' when appropriate.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Kees Cook <keescook@chromium.org>

Richard, can you take these?

> ---
> I don't know why it has not already been replaced in 6da2ec56059c
> ("treewide: kmalloc() -> kmalloc_array()".

Hm, not sure. I'd guess it was from the ()s and some Coccinelle rule
missing handling that. I thought I caught them all. :P

> ---
>  arch/um/drivers/vector_kern.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 5b917716289d..dee5246bda81 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -507,12 +507,12 @@ static struct vector_queue *create_queue(
>                 return NULL;
>         result->max_depth = max_size;
>         result->dev = vp->dev;
> -       result->mmsg_vector = kmalloc(
> -               (sizeof(struct mmsghdr) * max_size), GFP_KERNEL);
> +       result->mmsg_vector = kmalloc_array(max_size, sizeof(struct mmsghdr),
> +                                           GFP_KERNEL);
>         if (result->mmsg_vector == NULL)
>                 goto out_mmsg_fail;
> -       result->skbuff_vector = kmalloc(
> -               (sizeof(void *) * max_size), GFP_KERNEL);
> +       result->skbuff_vector = kmalloc_array(max_size, sizeof(void *),
> +                                             GFP_KERNEL);
>         if (result->skbuff_vector == NULL)
>                 goto out_skb_fail;
>
> --
> 2.19.1
>


-- 
Kees Cook

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-08 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-26  7:54 [PATCH 2/2] um: vector: Use 'kmalloc_array' instead of 'kmalloc' Christophe JAILLET
2019-01-02 16:34 ` Anton Ivanov
2019-01-08 23:58 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®