Skip to contentSkip to conversation

pstore/ram: (really) fix undefined usage of rounddown_pow_of_two

PATCH Applied Maxime Bizon 3 participants 3 messages Aug 30, 2013 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pstore/ram: (really) fix undefined usage of rounddown_pow_of_two

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).

---
 fs/pstore/ram.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/pstore/ram.c +3 -3
index a6119f9..03325bc 100644
@@ -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;
Signature · 5 lines
1.7.9.5


-- 
Maxime
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Maxime Bizon

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).

Yes, excellent point. :)

Thanks,

-Kees

Quoted 31 lines
---
 fs/pstore/ram.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/pstore/ram.c +3 -4
index a6119f9..03325bc 100644
@@ -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

Signature · 2 lines
Kees Cook
Chrome OS Security