Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758754Ab2JSMAW (ORCPT ); Fri, 19 Oct 2012 08:00:22 -0400 Received: from zmc.proxad.net ([212.27.53.206]:55071 "EHLO zmc.proxad.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752432Ab2JSMAV (ORCPT ); Fri, 19 Oct 2012 08:00:21 -0400 From: Florian Fainelli To: cbouatmailru@gmail.com Cc: ccross@android.com, keescook@chromium.org, tony.luck@intel.com, linux-kernel@vger.kernel.org, Maxime Bizon , Florian Fainelli , stable@vger.kernel.org Subject: [PATCH] pstore/ram: fix undefined usage of rounddown_pow_of_two. Date: Fri, 19 Oct 2012 13:59:02 +0200 Message-Id: <1350647942-5260-1-git-send-email-ffainelli@freebox.fr> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1648 Lines: 44 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); + if (pdata->record_size) + pdata->record_size = rounddown_pow_of_two(pdata->record_size); + if (pdata->console_size) + pdata->console_size = rounddown_pow_of_two(pdata->console_size); + if (pdata->ftrace_size) + pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); cxt->dump_read_cnt = 0; cxt->size = pdata->mem_size; -- 1.7.9.5 -- 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/