linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: ti-sysc: Use 2-factor allocator arguments
@ 2018-06-18 17:45 Kees Cook
  2018-06-27 21:56 ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2018-06-18 17:45 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-kernel, Arnd Bergmann

This adjusts the allocator calls to use 2-factor argument call style, as
done treewide already for improved defense against allocation overflows.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/bus/ti-sysc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 1cc29629d238..80d60f43db56 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -169,9 +169,9 @@ static int sysc_get_clocks(struct sysc *ddata)
 	const char *name;
 	int nr_fck = 0, nr_ick = 0, i, error = 0;
 
-	ddata->clock_roles = devm_kzalloc(ddata->dev,
-					  sizeof(*ddata->clock_roles) *
+	ddata->clock_roles = devm_kcalloc(ddata->dev,
 					  SYSC_MAX_CLOCKS,
+					  sizeof(*ddata->clock_roles),
 					  GFP_KERNEL);
 	if (!ddata->clock_roles)
 		return -ENOMEM;
@@ -200,8 +200,8 @@ static int sysc_get_clocks(struct sysc *ddata)
 		return -EINVAL;
 	}
 
-	ddata->clocks = devm_kzalloc(ddata->dev,
-				     sizeof(*ddata->clocks) * ddata->nr_clocks,
+	ddata->clocks = devm_kcalloc(ddata->dev,
+				     ddata->nr_clocks, sizeof(*ddata->clocks),
 				     GFP_KERNEL);
 	if (!ddata->clocks)
 		return -ENOMEM;
-- 
2.17.0


-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] bus: ti-sysc: Use 2-factor allocator arguments
  2018-06-18 17:45 [PATCH] bus: ti-sysc: Use 2-factor allocator arguments Kees Cook
@ 2018-06-27 21:56 ` Kees Cook
  2018-07-02 11:27   ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2018-06-27 21:56 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: LKML, Arnd Bergmann

On Mon, Jun 18, 2018 at 10:45 AM, Kees Cook <keescook@chromium.org> wrote:
> This adjusts the allocator calls to use 2-factor argument call style, as
> done treewide already for improved defense against allocation overflows.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>

Friendly ping! :) This is the last 2-factor devm* allocation left in
4.18 to be fixed.

Thanks!

-Kees

> ---
>  drivers/bus/ti-sysc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
> index 1cc29629d238..80d60f43db56 100644
> --- a/drivers/bus/ti-sysc.c
> +++ b/drivers/bus/ti-sysc.c
> @@ -169,9 +169,9 @@ static int sysc_get_clocks(struct sysc *ddata)
>         const char *name;
>         int nr_fck = 0, nr_ick = 0, i, error = 0;
>
> -       ddata->clock_roles = devm_kzalloc(ddata->dev,
> -                                         sizeof(*ddata->clock_roles) *
> +       ddata->clock_roles = devm_kcalloc(ddata->dev,
>                                           SYSC_MAX_CLOCKS,
> +                                         sizeof(*ddata->clock_roles),
>                                           GFP_KERNEL);
>         if (!ddata->clock_roles)
>                 return -ENOMEM;
> @@ -200,8 +200,8 @@ static int sysc_get_clocks(struct sysc *ddata)
>                 return -EINVAL;
>         }
>
> -       ddata->clocks = devm_kzalloc(ddata->dev,
> -                                    sizeof(*ddata->clocks) * ddata->nr_clocks,
> +       ddata->clocks = devm_kcalloc(ddata->dev,
> +                                    ddata->nr_clocks, sizeof(*ddata->clocks),
>                                      GFP_KERNEL);
>         if (!ddata->clocks)
>                 return -ENOMEM;
> --
> 2.17.0
>
>
> --
> Kees Cook
> Pixel Security



-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] bus: ti-sysc: Use 2-factor allocator arguments
  2018-06-27 21:56 ` Kees Cook
@ 2018-07-02 11:27   ` Tony Lindgren
  2018-07-02 16:14     ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2018-07-02 11:27 UTC (permalink / raw)
  To: Kees Cook; +Cc: LKML, Arnd Bergmann

* Kees Cook <keescook@chromium.org> [180627 21:59]:
> On Mon, Jun 18, 2018 at 10:45 AM, Kees Cook <keescook@chromium.org> wrote:
> > This adjusts the allocator calls to use 2-factor argument call style, as
> > done treewide already for improved defense against allocation overflows.
> >
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> 
> Friendly ping! :) This is the last 2-factor devm* allocation left in
> 4.18 to be fixed.

Sorry for the delay on this one. As we're already at -rc3, I'll apply
this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush
this into v4.18-rc cycle, but please do let me know if that is not the
case.

Regards,

Tony

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

* Re: [PATCH] bus: ti-sysc: Use 2-factor allocator arguments
  2018-07-02 11:27   ` Tony Lindgren
@ 2018-07-02 16:14     ` Kees Cook
  2018-07-03  6:20       ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2018-07-02 16:14 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: LKML, Arnd Bergmann

On Mon, Jul 2, 2018 at 4:27 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Kees Cook <keescook@chromium.org> [180627 21:59]:
>> On Mon, Jun 18, 2018 at 10:45 AM, Kees Cook <keescook@chromium.org> wrote:
>> > This adjusts the allocator calls to use 2-factor argument call style, as
>> > done treewide already for improved defense against allocation overflows.
>> >
>> > Signed-off-by: Kees Cook <keescook@chromium.org>
>>
>> Friendly ping! :) This is the last 2-factor devm* allocation left in
>> 4.18 to be fixed.
>
> Sorry for the delay on this one. As we're already at -rc3, I'll apply
> this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush
> this into v4.18-rc cycle, but please do let me know if that is not the
> case.

I'd like to be able to reason about multiplication vs allocator uses
in 4.18 and later. Since all other allocators got fixed in 4.18, I'd
really like to have this one fixed too, then the scripts that check
for multiplications in single-argument allocators will run clean for
4.18.

So, it's not strictly a "rush", but it would be appreciated. :)

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] bus: ti-sysc: Use 2-factor allocator arguments
  2018-07-02 16:14     ` Kees Cook
@ 2018-07-03  6:20       ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2018-07-03  6:20 UTC (permalink / raw)
  To: Kees Cook; +Cc: LKML, Arnd Bergmann

* Kees Cook <keescook@chromium.org> [180702 16:17]:
> On Mon, Jul 2, 2018 at 4:27 AM, Tony Lindgren <tony@atomide.com> wrote:
> > * Kees Cook <keescook@chromium.org> [180627 21:59]:
> >> On Mon, Jun 18, 2018 at 10:45 AM, Kees Cook <keescook@chromium.org> wrote:
> >> > This adjusts the allocator calls to use 2-factor argument call style, as
> >> > done treewide already for improved defense against allocation overflows.
> >> >
> >> > Signed-off-by: Kees Cook <keescook@chromium.org>
> >>
> >> Friendly ping! :) This is the last 2-factor devm* allocation left in
> >> 4.18 to be fixed.
> >
> > Sorry for the delay on this one. As we're already at -rc3, I'll apply
> > this into omap-for-v4.19/ti-sysc. Seems there should not be need to rush
> > this into v4.18-rc cycle, but please do let me know if that is not the
> > case.
> 
> I'd like to be able to reason about multiplication vs allocator uses
> in 4.18 and later. Since all other allocators got fixed in 4.18, I'd
> really like to have this one fixed too, then the scripts that check
> for multiplications in single-argument allocators will run clean for
> 4.18.
> 
> So, it's not strictly a "rush", but it would be appreciated. :)

OK I'll merge that commit also into omap-for-v4.18/fixes branch
too.

Regards,

Tony

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

end of thread, other threads:[~2018-07-03  6:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 17:45 [PATCH] bus: ti-sysc: Use 2-factor allocator arguments Kees Cook
2018-06-27 21:56 ` Kees Cook
2018-07-02 11:27   ` Tony Lindgren
2018-07-02 16:14     ` Kees Cook
2018-07-03  6:20       ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).