mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
	bcm-kernel-feedback-list@broadcom.com, linux-clk@vger.kernel.org,
	Florian Fainelli <f.fainelli@gmail.com>,
	Matt Porter <mporter@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Vaishali Thakkar <vaishali.thakkar@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] clk-kona-setup: Use kmalloc_array() in parent_process()
Date: Wed, 14 Sep 2016 13:45:11 -0500	[thread overview]
Message-ID: <887a42c4-6cff-6d03-c62a-ffd3da128738@linaro.org> (raw)
In-Reply-To: <1fb2e894-93d3-3dbe-ca05-7e29e4c60e2a@users.sourceforge.net>

On 09/14/2016 01:40 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 20:26:05 +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".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Probably not needed in practice, but safer nevertheless.

Reviewed-by: Alex Elder <elder@linaro.org>

> ---
>  drivers/clk/bcm/clk-kona-setup.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c
> index 526b0b0..a2e7e91 100644
> --- a/drivers/clk/bcm/clk-kona-setup.c
> +++ b/drivers/clk/bcm/clk-kona-setup.c
> @@ -586,8 +586,9 @@ static u32 *parent_process(const char *clocks[],
>  	}
>  
>  	/* There is at least one parent, so allocate a selector array */
> -
> -	parent_sel = kmalloc(parent_count * sizeof(*parent_sel), GFP_KERNEL);
> +	parent_sel = kmalloc_array(parent_count,
> +				   sizeof(*parent_sel),
> +				   GFP_KERNEL);
>  	if (!parent_sel) {
>  		pr_err("%s: error allocating %u parent selectors\n", __func__,
>  				parent_count);
> 

  reply	other threads:[~2016-09-14 18:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14 18:40 SF Markus Elfring
2016-09-14 18:45 ` Alex Elder [this message]
2016-09-14 20:47 ` Stephen Boyd

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=887a42c4-6cff-6d03-c62a-ffd3da128738@linaro.org \
    --to=elder@linaro.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=elfring@users.sourceforge.net \
    --cc=f.fainelli@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@linaro.org \
    --cc=mturquette@baylibre.com \
    --cc=rjui@broadcom.com \
    --cc=sboyd@codeaurora.org \
    --cc=sbranden@broadcom.com \
    --cc=vaishali.thakkar@oracle.com \
    /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 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®