mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pstore/ram: (really) fix undefined usage of rounddown_pow_of_two
@ 2013-08-30 16:06 Maxime Bizon
  2013-08-30 18:15 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Bizon @ 2013-08-30 16:06 UTC (permalink / raw)
  To: Anton Vorontsov, Colin Cross, Kees Cook, Tony Luck; +Cc: linux-kernel

Previous attempt to fix was b042e47491ba5f487601b5141a3f1d8582304170

Suggested use of is_power_of_2() was bogus because is_power_of_2(0) is
false (documented behaviour).

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
 fs/pstore/ram.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index a6119f9..03325bc 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -400,11 +400,11 @@ static int ramoops_probe(struct platform_device *pdev)
 		goto fail_out;
 	}
 
-	if (!is_power_of_2(pdata->record_size))
+	if (pdata->record_size && !is_power_of_2(pdata->record_size))
 		pdata->record_size = rounddown_pow_of_two(pdata->record_size);
-	if (!is_power_of_2(pdata->console_size))
+	if (pdata->console_size && !is_power_of_2(pdata->console_size))
 		pdata->console_size = rounddown_pow_of_two(pdata->console_size);
-	if (!is_power_of_2(pdata->ftrace_size))
+	if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size))
 		pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
 
 	cxt->dump_read_cnt = 0;
-- 
1.7.9.5


-- 
Maxime



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

* Re: [PATCH] pstore/ram: (really) fix undefined usage of rounddown_pow_of_two
  2013-08-30 16:06 [PATCH] pstore/ram: (really) fix undefined usage of rounddown_pow_of_two Maxime Bizon
@ 2013-08-30 18:15 ` Kees Cook
  2013-08-30 23:05   ` Luck, Tony
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2013-08-30 18:15 UTC (permalink / raw)
  To: Maxime Bizon; +Cc: Anton Vorontsov, Colin Cross, Tony Luck, LKML

On Fri, Aug 30, 2013 at 9:06 AM, Maxime Bizon <mbizon@freebox.fr> wrote:
> Previous attempt to fix was b042e47491ba5f487601b5141a3f1d8582304170
>
> Suggested use of is_power_of_2() was bogus because is_power_of_2(0) is
> false (documented behaviour).
>
> Signed-off-by: Maxime Bizon <mbizon@freebox.fr>

Yes, excellent point. :)

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

Thanks,

-Kees

> ---
>  fs/pstore/ram.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index a6119f9..03325bc 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -400,11 +400,11 @@ static int ramoops_probe(struct platform_device *pdev)
>                 goto fail_out;
>         }
>
> -       if (!is_power_of_2(pdata->record_size))
> +       if (pdata->record_size && !is_power_of_2(pdata->record_size))
>                 pdata->record_size = rounddown_pow_of_two(pdata->record_size);
> -       if (!is_power_of_2(pdata->console_size))
> +       if (pdata->console_size && !is_power_of_2(pdata->console_size))
>                 pdata->console_size = rounddown_pow_of_two(pdata->console_size);
> -       if (!is_power_of_2(pdata->ftrace_size))
> +       if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size))
>                 pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
>
>         cxt->dump_read_cnt = 0;
> --
> 1.7.9.5
>
>
> --
> Maxime
>
>



-- 
Kees Cook
Chrome OS Security

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

* RE: [PATCH] pstore/ram: (really) fix undefined usage of rounddown_pow_of_two
  2013-08-30 18:15 ` Kees Cook
@ 2013-08-30 23:05   ` Luck, Tony
  0 siblings, 0 replies; 3+ messages in thread
From: Luck, Tony @ 2013-08-30 23:05 UTC (permalink / raw)
  To: Kees Cook, Maxime Bizon; +Cc: Anton Vorontsov, Colin Cross, LKML

>> Previous attempt to fix was b042e47491ba5f487601b5141a3f1d8582304170
>>
>> Suggested use of is_power_of_2() was bogus because is_power_of_2(0) is
>> false (documented behaviour).
>>
>> Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
>
> Yes, excellent point. :)
>
> Acked-by: Kees Cook <keescook@chromium.org>

Applied.  Thanks.

-Tony

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

end of thread, other threads:[~2013-08-30 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-30 16:06 [PATCH] pstore/ram: (really) fix undefined usage of rounddown_pow_of_two Maxime Bizon
2013-08-30 18:15 ` Kees Cook
2013-08-30 23:05   ` Luck, Tony

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®