From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751560AbdAPKsF (ORCPT ); Mon, 16 Jan 2017 05:48:05 -0500 Received: from mail.skyhub.de ([78.46.96.112]:47971 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751486AbdAPKsA (ORCPT ); Mon, 16 Jan 2017 05:48:00 -0500 Date: Mon, 16 Jan 2017 11:47:46 +0100 From: Borislav Petkov To: Arvind Yadav Cc: ravi@jetztechnologies.com, arvino55@gmail.com, mchehab@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] edac: i82975x_edac :- Handle return NULL error from ioremap_nocache Message-ID: <20170116104746.ouvbywtnfxwo5y2l@pd.tnic> References: <1484549092-11349-1-git-send-email-arvind.yadav.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1484549092-11349-1-git-send-email-arvind.yadav.cs@gmail.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 16, 2017 at 12:14:52PM +0530, Arvind Yadav wrote: > Here, If ioremap_nocache will fail. It will return NULL. > Kernel can run into a NULL-pointer dereference. > This error check will avoid NULL pointer dereference. > > Signed-off-by: Arvind Yadav > --- > drivers/edac/i82975x_edac.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c > index 7baa8ac..e747d82 100644 > --- a/drivers/edac/i82975x_edac.c > +++ b/drivers/edac/i82975x_edac.c > @@ -494,6 +494,10 @@ static int i82975x_probe1(struct pci_dev *pdev, int dev_idx) > } > mchbar &= 0xffffc000; /* bits 31:14 used for 16K window */ > mch_window = ioremap_nocache(mchbar, 0x1000); > + if (!mch_window) { > + edac_dbg(3, "failed to memory map!\n"); > + goto fail0; > + } > > #ifdef i82975x_DEBUG_IOMEM > i82975x_printk(KERN_INFO, "MCHBAR real = %0x, remapped = %p\n", > -- Applied, thanks. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.