From patchwork Tue Dec 13 08:20:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9471891 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 ABA9B607EE for ; Tue, 13 Dec 2016 08:21:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AB24284CE for ; Tue, 13 Dec 2016 08:21:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E2B3284F3; Tue, 13 Dec 2016 08:21:17 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 4FC7C284CE for ; Tue, 13 Dec 2016 08:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932232AbcLMIVP (ORCPT ); Tue, 13 Dec 2016 03:21:15 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33610 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932220AbcLMIVP (ORCPT ); Tue, 13 Dec 2016 03:21:15 -0500 Received: by mail-pg0-f65.google.com with SMTP id 3so3784554pgd.0; Tue, 13 Dec 2016 00:21:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=y7SO21uncautvMDzG3V5IC6gNM2QQIw+o+OtMoeyoRc=; b=LYI45hBB/DVkLvxCewp894KMTVC/FgMoaUWNtKFI31BK2RTDw6UcaiY/yr27Hba1mI Sjh7W2WaiHLqCbvc7449stDNAJ811uxBIn2ahEgwO+Jjy1Nd9+QqBkjR5lMl2mFqdrmv t5QSf5luqErOnZ3qo7iVJUiStZCUES2LsQHE4tNaG5MP6QauXx+tmudkeQHNzRZ3uWDW LXkhBe8HSoZ1+OGg+YJjbynAReaVE+55OydodDQhhPu+EPdaiTuK7zItZLfjIR6tYhiT GGC0kd2ZYbe6YqK3YMDbOmKQmyoffx3laBEqxmkTVhULtQ7g5LKCRh3a7tqLnOhSbQ7Z Iv2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=y7SO21uncautvMDzG3V5IC6gNM2QQIw+o+OtMoeyoRc=; b=W0tt42sKjmZn7bdkpQW6j9v04yU0hbYno8MJWydxyDIZP1cp6aeVPbLp+iBgomKTKk eyApRba+mn9Ic8OtzIS+y6yxgFUojE1qj9dGLSpTRaQVjBSFon30kx7fZJPrUMoeHPX3 06qsw73iGQ1ylXkFjk8kETGFlniXBGB2TRPKCpv8tdRa4vrLxdPmzoW1RWZzhr5uBjcl 04AAXsUHEGQF67nC+jRx6mlN3Qq1slMz5Kjzn4q0qUnKXA3m8N++b2vwpasedQyQxY+s l7l4qt9qr0cSmM9aHK5+yvXf8iHPF/djSkcOOyG8Tzi0LaVleqrZVw2siiUVQ14CqTKt 4Wtw== X-Gm-Message-State: AKaTC00D/EtVxX6UDan5FpPKwpXMMYStaLNxMmVn8vfFJc8gDQVlSkSW5YcZsn4tCN3rUg== X-Received: by 10.84.213.150 with SMTP id g22mr194340519pli.11.1481617274406; Tue, 13 Dec 2016 00:21:14 -0800 (PST) Received: from localhost.localdomain ([103.16.70.17]) by smtp.gmail.com with ESMTPSA id y66sm79830658pgb.21.2016.12.13.00.21.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Dec 2016 00:21:13 -0800 (PST) From: Arvind Yadav To: tomi.valkeinen@ti.com Cc: ralf@linux-mips.org, paul.burton@imgtec.com, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v1] video:fbdev:cobalt_lcdfb:- Handle return NULL error from devm_ioremap Date: Tue, 13 Dec 2016 13:50:52 +0530 Message-Id: <1481617252-8298-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Here, If devm_ioremap 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 Acked-by: Yoichi Yuasa --- drivers/video/fbdev/cobalt_lcdfb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c index 2d3b691..038ac69 100644 --- a/drivers/video/fbdev/cobalt_lcdfb.c +++ b/drivers/video/fbdev/cobalt_lcdfb.c @@ -308,6 +308,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev) info->screen_size = resource_size(res); info->screen_base = devm_ioremap(&dev->dev, res->start, info->screen_size); + if (!info->screen_base) { + framebuffer_release(info); + return -ENOMEM; + } + info->fbops = &cobalt_lcd_fbops; info->fix = cobalt_lcdfb_fix; info->fix.smem_start = res->start;