From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751606AbcL0HHD (ORCPT ); Tue, 27 Dec 2016 02:07:03 -0500 Received: from mail.skyhub.de ([78.46.96.112]:60746 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbcL0HG4 (ORCPT ); Tue, 27 Dec 2016 02:06:56 -0500 Date: Tue, 27 Dec 2016 08:06:47 +0100 From: Borislav Petkov To: Thomas Gleixner Cc: Linus Torvalds , LKML , Ingo Molnar , Peter Zijlstra , Markus Trippelsdorf , Boris Ostrovsky Subject: Re: [patch 2/2] x86/mce/AMD: Make the init code more robust Message-ID: <20161227070646.GA8366@nazgul.tnic> References: <20161226215818.438870590@linutronix.de> <20161226220019.772709435@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161226220019.772709435@linutronix.de> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 26, 2016 at 10:58:20PM +0100, Thomas Gleixner wrote: > If mce_device_init() fails then the mce device pointer is NULL and the AMD > mce code happily dereferences it. > > Add a sanity check. > > Reported-by: Markus Trippelsdorf > Reported-by: Boris Ostrovsky > Signed-off-by: Thomas Gleixner > --- > arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 +++ > 1 file changed, 3 insertions(+) > > --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c > +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c > @@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigne > const char *name = get_name(bank, NULL); > int err = 0; > > + if (!dev) > + return -ENODEV; > + > if (is_shared_bank(bank)) { > nb = node_to_amd_nb(amd_get_nb_id(cpu)); Acked-by: Borislav Petkov >>From looking at that code, though, it could use some more involved straightening later. /me puts it on TODO list. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --