From patchwork Thu Jan 19 08:00:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9525263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1759760437 for ; Thu, 19 Jan 2017 08:09:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A9DB28510 for ; Thu, 19 Jan 2017 08:09:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F26D42854A; Thu, 19 Jan 2017 08:09:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7898828510 for ; Thu, 19 Jan 2017 08:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750938AbdASIJ5 (ORCPT ); Thu, 19 Jan 2017 03:09:57 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:36843 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750900AbdASIJ4 (ORCPT ); Thu, 19 Jan 2017 03:09:56 -0500 Received: by mail-it0-f66.google.com with SMTP id o138so4223333ito.3 for ; Thu, 19 Jan 2017 00:09:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mEgBSQmVkPTre2PcVZAs657LUMD35PEd+B4gi+ReYlA=; b=fKrhPn10bHvOCcTt6QUPURRa3dga/MAnsGBBkRG/GTLBT8F5AUz6bJaEOCPKUEu+4w NZCW20J0mf5H29dDqO8Us/lOpUQutwYF2OFTdf2utd71ZBuIuoBVqC3m/9nyr3CxZiXP PwNLITrQ+MUA/6RI20SjPEZ1QVu0IxU0sVFJfNZTrXXJUUA56ny6I4r/UG8iK29gUIa/ czNQREM2q1Hj4IvbHmBrGDAHHeudNJqe48BJ8eNEiCjdHbGJoxaEykOSg1B/j/h0eCTV 3wFT8VcYsEAa7OldI/8R20nCcYtEjaYaE0TliPqjoeeoQlcbRhrXOzq4GtKXFpR7/SRq 7+xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mEgBSQmVkPTre2PcVZAs657LUMD35PEd+B4gi+ReYlA=; b=DEZUlP67CjYtcMoDJH62V6uYwCbETcl0Fm+spJeLUl8jwCLDjX7hMod6Evfq+u6J9s QpCkHOHX1iie+bOIINv/fwWl3Asquu6q92jz5dyNiTV28LlA6QSzPgVZhqdrheOEUHLK JAtOLLJEhnzXpk/bW6GFAiVXNcIgIeOcau+Gb9mFzV/C59FHnRQhGwRmHAfkQ40KzrdU jJiZ8VPTrrV+bW5b1JtBuPYaLHfM10ycaitSNaIF3Ffykfl++GCOrl6WXGP3Ab84o4rM zBbTUszpdsUrsBfk9KfWE6wNFVDw8IfCSKZQB/F/7gYPWGE7+lfTHUtV68AuD9q37h2O 1Eww== X-Gm-Message-State: AIkVDXKU9/Sjll9oc/wzE3sLfp6BBm9Nh5mesHh2/Pq2tc7UiJoAbO/sUFzxkU1RK4mXsA== X-Received: by 10.36.58.198 with SMTP id m189mr6914881itm.105.1484812882680; Thu, 19 Jan 2017 00:01:22 -0800 (PST) Received: from symbol-HP-Z420-Workstation.zebra.lan ([223.31.70.102]) by smtp.googlemail.com with ESMTPSA id p81sm2460385ioi.9.2017.01.19.00.01.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 00:01:22 -0800 (PST) From: Arvind Yadav To: jejb@parisc-linux.org, deller@gmx.de, gregkh@linuxfoundation.org Cc: jslaby@suse.com, linux-parisc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] tty: serial: 8250: 8250_gsc:- Handle return NULL error from ioremap_nocache Date: Thu, 19 Jan 2017 13:30:44 +0530 Message-Id: <1484812844-10598-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/tty/serial/8250/8250_gsc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/8250/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c index b1e6ae9..63306de 100644 --- a/drivers/tty/serial/8250/8250_gsc.c +++ b/drivers/tty/serial/8250/8250_gsc.c @@ -60,6 +60,10 @@ static int __init serial_init_chip(struct parisc_device *dev) 7272727 : 1843200; uart.port.mapbase = address; uart.port.membase = ioremap_nocache(address, 16); + if (!uart.port.membase) { + dev_warn(&dev->dev, "Failed to map memory\n"); + return -ENOMEM; + } uart.port.irq = dev->irq; uart.port.flags = UPF_BOOT_AUTOCONF; uart.port.dev = &dev->dev;