All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-input@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 1/4] Input-gameport: Use kmalloc_array() in joydump_connect()
Date: Sat, 24 Sep 2016 16:42:51 +0000	[thread overview]
Message-ID: <20160924164251.GC40187@dtor-ws> (raw)
In-Reply-To: <7ff91d13-9111-c75a-1c1a-e119025866e7@users.sourceforge.net>

On Sat, Sep 24, 2016 at 03:46:21PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 24 Sep 2016 13:50:20 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 

-ENOPARSE.

>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/input/joystick/joydump.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
> index d1c6e48..e515058 100644
> --- a/drivers/input/joystick/joydump.c
> +++ b/drivers/input/joystick/joydump.c
> @@ -79,8 +79,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr
>  	}
>  
>  	timeout = gameport_time(gameport, 10000); /* 10 ms */
> -
> -	buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
> +	buf = kmalloc_array(BUF_SIZE, sizeof(*buf), GFP_KERNEL);
>  	if (!buf) {
>  		printk(KERN_INFO "joydump: no memory for testing\n");
>  		goto jd_end;
> -- 
> 2.10.0
> 

-- 
Dmitry

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-input@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 1/4] Input-gameport: Use kmalloc_array() in joydump_connect()
Date: Sat, 24 Sep 2016 09:42:51 -0700	[thread overview]
Message-ID: <20160924164251.GC40187@dtor-ws> (raw)
In-Reply-To: <7ff91d13-9111-c75a-1c1a-e119025866e7@users.sourceforge.net>

On Sat, Sep 24, 2016 at 03:46:21PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 24 Sep 2016 13:50:20 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 

-ENOPARSE.

>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/input/joystick/joydump.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
> index d1c6e48..e515058 100644
> --- a/drivers/input/joystick/joydump.c
> +++ b/drivers/input/joystick/joydump.c
> @@ -79,8 +79,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr
>  	}
>  
>  	timeout = gameport_time(gameport, 10000); /* 10 ms */
> -
> -	buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
> +	buf = kmalloc_array(BUF_SIZE, sizeof(*buf), GFP_KERNEL);
>  	if (!buf) {
>  		printk(KERN_INFO "joydump: no memory for testing\n");
>  		goto jd_end;
> -- 
> 2.10.0
> 

-- 
Dmitry

  reply	other threads:[~2016-09-24 16:42 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-24 13:45 [PATCH 0/4] Input-gameport: Fine-tuning for joydump_connect() SF Markus Elfring
2016-09-24 13:45 ` SF Markus Elfring
2016-09-24 13:46 ` [PATCH 1/4] Input-gameport: Use kmalloc_array() in joydump_connect() SF Markus Elfring
2016-09-24 13:46   ` SF Markus Elfring
2016-09-24 16:42   ` Dmitry Torokhov [this message]
2016-09-24 16:42     ` Dmitry Torokhov
2016-09-24 17:04     ` SF Markus Elfring
2016-09-24 17:04       ` SF Markus Elfring
2016-09-24 13:47 ` [PATCH 2/4] Input-gameport: Delete an error message for a failed memory allocation SF Markus Elfring
2016-09-24 13:47   ` SF Markus Elfring
2016-09-24 13:48 ` [PATCH 3/4] Input-gameport: Add the macro "pr_fmt" for module "joydump" SF Markus Elfring
2016-09-24 13:48   ` SF Markus Elfring
2016-09-24 16:41   ` Dmitry Torokhov
2016-09-24 16:41     ` Dmitry Torokhov
2016-09-24 16:55     ` SF Markus Elfring
2016-09-24 16:55       ` SF Markus Elfring
2016-09-24 17:03       ` Joe Perches
2016-09-24 17:03         ` Joe Perches
2016-09-24 17:45         ` SF Markus Elfring
2016-09-24 17:45           ` SF Markus Elfring
2016-09-24 18:01           ` Joe Perches
2016-09-24 18:01             ` Joe Perches
2016-09-24 18:45             ` SF Markus Elfring
2016-09-24 18:45               ` SF Markus Elfring
2016-09-24 13:50 ` [PATCH 4/4] Input-gameport: Replace some printk() calls by pr_info() in joydump_connect() SF Markus Elfring
2016-09-24 13:50   ` SF Markus Elfring
2016-09-24 16:13   ` Joe Perches
2016-09-24 16:13     ` Joe Perches
2016-09-24 16:32     ` SF Markus Elfring
2016-09-24 16:32       ` SF Markus Elfring
2016-09-24 16:39       ` Dmitry Torokhov
2016-09-24 16:39         ` Dmitry Torokhov
2016-09-24 17:20         ` SF Markus Elfring
2016-09-24 17:20           ` SF Markus Elfring
2016-09-24 16:47       ` [PATCH 4/4] " Joe Perches
2016-09-24 16:47         ` Joe Perches
2016-09-24 19:50         ` SF Markus Elfring
2016-09-24 19:50           ` SF Markus Elfring
2016-09-24 16:41     ` [PATCH 4/4] " SF Markus Elfring
2016-09-24 16:41       ` SF Markus Elfring
2016-09-25  7:15     ` [PATCH v2 3/3] " SF Markus Elfring
2016-09-25  7:15       ` SF Markus Elfring
2016-09-25  7:31       ` Joe Perches
2016-09-25  7:31         ` Joe Perches
2016-09-25  7:45         ` SF Markus Elfring
2016-09-25  7:45           ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160924164251.GC40187@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=elfring@users.sourceforge.net \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.