Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752257Ab2JVIi3 (ORCPT ); Mon, 22 Oct 2012 04:38:29 -0400 Received: from zmc.proxad.net ([212.27.53.206]:37403 "EHLO zmc.proxad.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434Ab2JVIi1 (ORCPT ); Mon, 22 Oct 2012 04:38:27 -0400 From: Florian Fainelli To: Kees Cook Cc: cbouatmailru@gmail.com, ccross@android.com, tony.luck@intel.com, linux-kernel@vger.kernel.org, Maxime Bizon , stable@vger.kernel.org Subject: Re: [PATCH] pstore/ram: fix undefined usage of rounddown_pow_of_two. Date: Mon, 22 Oct 2012 10:37:10 +0200 Message-ID: <1807287.lsQvlHRIOP@flexo> Organization: Freebox User-Agent: KMail/4.8.5 (Linux/3.2.0-24-generic; KDE/4.8.5; x86_64; ; ) In-Reply-To: References: <1350647942-5260-1-git-send-email-ffainelli@freebox.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1759 Lines: 42 On Friday 19 October 2012 09:03:12 Kees Cook wrote: > On Fri, Oct 19, 2012 at 4:59 AM, Florian Fainelli wrote: > > From: Maxime Bizon > > > > record_size / console_size / ftrace_size can be 0 (this is how you > > disable the feature), but rounddown_pow_of_two(0) is undefined. This problem > > has been present since commit 1894a253 (ramoops: Move to fs/pstore/ram.c). > > > > Signed-off-by: Maxime Bizon > > Signed-off-by: Florian Fainelli > > CC: stable@vger.kernel.org > > --- > > fs/pstore/ram.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > > index 1a4f6da..0c2ae26 100644 > > --- a/fs/pstore/ram.c > > +++ b/fs/pstore/ram.c > > @@ -374,10 +374,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev) > > goto fail_out; > > } > > > > - pdata->mem_size = rounddown_pow_of_two(pdata->mem_size); > > - pdata->record_size = rounddown_pow_of_two(pdata->record_size); > > - pdata->console_size = rounddown_pow_of_two(pdata->console_size); > > - pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); > > + if (pdata->mem_size) > > + pdata->mem_size = rounddown_pow_of_two(pdata->mem_size); > > Nice catch! > > Instead of the == 0 check, what about using !is_power_of_2(size) ? That would work equally well, I will resubmit with this then. -- Florian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/