]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
pstore/ram: Fix undefined usage of rounddown_pow_of_two(0)
authorMaxime Bizon <mbizon@freebox.fr>
Mon, 22 Oct 2012 09:19:28 +0000 (11:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:45:58 +0000 (08:45 -0800)
commita8a491ca60238bc7c031f7731a5730aa06b6dda7
tree640bffcdbaf15a81f775d65e4896115430504993
parentb82212de08b20b70efe679cd4c8579c13771e610
pstore/ram: Fix undefined usage of rounddown_pow_of_two(0)

commit b042e47491ba5f487601b5141a3f1d8582304170 upstream.

record_size / console_size / ftrace_size can be 0 (this is how you disable
the feature), but rounddown_pow_of_two(0) is undefined. As suggested by
Kees Cook, use !is_power_of_2() as a condition to call
rounddown_pow_of_two and avoid its undefined behavior on the value 0. This
issue has been present since commit 1894a253 (ramoops: Move to
fs/pstore/ram.c).

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Florian Fainelli <ffainelli@freebox.fr>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/pstore/ram.c