From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbaDYLyG (ORCPT ); Fri, 25 Apr 2014 07:54:06 -0400 Received: from smtpfb1-g21.free.fr ([212.27.42.9]:44142 "EHLO smtpfb1-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbaDYLyC (ORCPT ); Fri, 25 Apr 2014 07:54:02 -0400 Message-ID: <535A4CBF.1090301@free.fr> Date: Fri, 25 Apr 2014 13:53:35 +0200 From: mathieu souchaud User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Borislav Petkov CC: tony.luck@intel.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] x86/mce: Check misc_register() return code. References: <1398419295-18590-1-git-send-email-mattieu.souchaud@free.fr> <20140425104256.GB18540@nazgul.tnic> In-Reply-To: <20140425104256.GB18540@nazgul.tnic> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Great, I will fix that soon. Thanks. Le 25/04/2014 12:42, Borislav Petkov a écrit : > On Fri, Apr 25, 2014 at 11:48:15AM +0200, Mathieu Souchaud wrote: >> The current code does not check the return from misc_register() so set >> the return variable with the return code of misc_register. >> >> Signed-off-by: Mathieu Souchaud >> --- >> arch/x86/kernel/cpu/mcheck/mce.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c >> index 68317c8..45fb7aa 100644 >> --- a/arch/x86/kernel/cpu/mcheck/mce.c >> +++ b/arch/x86/kernel/cpu/mcheck/mce.c >> @@ -2462,7 +2462,7 @@ static __init int mcheck_init_device(void) >> cpu_notifier_register_done(); >> >> /* register character device /dev/mcelog */ >> - misc_register(&mce_chrdev_device); >> + err = misc_register(&mce_chrdev_device); > This function mcheck_init_device() is a one big sloppy mess > of not handling the error cases responsibly. It doesn't check > zalloc_cpumask_var() retval, it doesn't free the mce_device_initialized > when subsys_system_register() fails, the same when mce_device_create > fails, the same with __register_hotcpu_notifier and finally with > misc_register. > > Would you be willing to fix this properly with goto labels and proper > unwinding, like it is done in other, saner places in the kernel, and > at the end maybe add a printk for the error case warning us that > /dev/mcelog didn't get registered? > > That would be a very nice cleanup! :-) > > Thanks.