From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758289Ab3KOL1p (ORCPT ); Fri, 15 Nov 2013 06:27:45 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:49000 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752951Ab3KOL1i (ORCPT ); Fri, 15 Nov 2013 06:27:38 -0500 Date: Fri, 15 Nov 2013 12:27:35 +0100 From: Ingo Molnar To: Felipe Contreras Cc: Linux Kernel Mailing List , Ingo Molnar , Linus Torvalds , Andrew Morton Subject: Re: [PATCH v2] panic: setup panic_timeout early Message-ID: <20131115112735.GA19004@gmail.com> References: <1384180814-21823-1-git-send-email-felipe.contreras@gmail.com> <20131113000358.GA2420@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Felipe Contreras wrote: > On Tue, Nov 12, 2013 at 6:03 PM, Ingo Molnar wrote: > > > >> +static int __init set_panic_timeout(char *val) > >> +{ > >> + long timeout; > >> + int ret; > >> + > >> + ret = kstrtol(val, 0, &timeout); > >> + if (ret < 0) > >> + return ret; > >> + > >> + panic_timeout = timeout; > >> + return 0; > >> +} > > > > I think the type of the 'timeout' local variable should match the type of > > 'panic_timeout' (which is 'int', not 'long'). > > So you would rather have this? > > kstrtol(val, 0, (long *)&timeout); > > Couldn't that potentially write the value beyond the memory > allocated to 'timeout'? No, casting that to 'long *' is actively wrong, I'd use a string -> integer conversion method that deals with ints, not longs, such as kstrtoint(). Thanks, Ingo