Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752932AbcLMIVT (ORCPT ); Tue, 13 Dec 2016 03:21:19 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 898 Lines: 27 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 --- 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; -- 2.7.4