* [PATCH] clk: unchecked return of kmalloc_array
@ 2015-12-14 13:16 Nicholas Mc Guire
2015-12-14 13:57 ` Nicholas Mc Guire
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2015-12-14 13:16 UTC (permalink / raw)
To: Michael Turquette
Cc: Stephen Boyd, Geert Uytterhoeven, Sebastian Hesselbarth,
Heiko Stuebner, linux-clk, linux-kernel, Nicholas Mc Guire
kmalloc_array return is unchecked - given how parent_names is being treated
in case of allocation error it probably is ok to treat clock->parents the
same way and simply return.
problem was located with coccinelle
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
patch was compile tested for shmobile_defconfig
(implies CONFIG_ARCH_SHMOBILE_MULTI=y)
patch is against linux-next (localversion-next -next-20151214)
drivers/clk/shmobile/clk-div6.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c
index b4c8d67..e6b7533 100644
--- a/drivers/clk/shmobile/clk-div6.c
+++ b/drivers/clk/shmobile/clk-div6.c
@@ -196,6 +196,8 @@ static void __init cpg_div6_clock_init(struct device_node *np)
clock->parents = kmalloc_array(num_parents, sizeof(*clock->parents),
GFP_KERNEL);
+ if (!clock->parents)
+ return;
parent_names = kmalloc_array(num_parents, sizeof(*parent_names),
GFP_KERNEL);
if (!parent_names)
--
1.7.10.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: unchecked return of kmalloc_array
2015-12-14 13:16 [PATCH] clk: unchecked return of kmalloc_array Nicholas Mc Guire
@ 2015-12-14 13:57 ` Nicholas Mc Guire
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas Mc Guire @ 2015-12-14 13:57 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: Michael Turquette, Stephen Boyd, Geert Uytterhoeven,
Sebastian Hesselbarth, Heiko Stuebner, linux-clk, linux-kernel
On Mon, Dec 14, 2015 at 02:16:55PM +0100, Nicholas Mc Guire wrote:
> kmalloc_array return is unchecked - given how parent_names is being treated
> in case of allocation error it probably is ok to treat clock->parents the
> same way and simply return.
>
> problem was located with coccinelle
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
>
> patch was compile tested for shmobile_defconfig
> (implies CONFIG_ARCH_SHMOBILE_MULTI=y)
>
> patch is against linux-next (localversion-next -next-20151214)
>
> drivers/clk/shmobile/clk-div6.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c
> index b4c8d67..e6b7533 100644
> --- a/drivers/clk/shmobile/clk-div6.c
> +++ b/drivers/clk/shmobile/clk-div6.c
> @@ -196,6 +196,8 @@ static void __init cpg_div6_clock_init(struct device_node *np)
>
> clock->parents = kmalloc_array(num_parents, sizeof(*clock->parents),
> GFP_KERNEL);
> + if (!clock->parents)
> + return;
> parent_names = kmalloc_array(num_parents, sizeof(*parent_names),
>
giving the callchain of kmalloc_array a look I guess there should be
some memset for parent_names and clock->parents - or is there a reason why
no memset would be needed here ?
thx!
hofrat
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-14 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-14 13:16 [PATCH] clk: unchecked return of kmalloc_array Nicholas Mc Guire
2015-12-14 13:57 ` Nicholas Mc Guire
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®