From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbcLUFWx (ORCPT ); Wed, 21 Dec 2016 00:22:53 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:35935 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbcLUFWu (ORCPT ); Wed, 21 Dec 2016 00:22:50 -0500 From: Arvind Yadav To: benjamin.gaignard@linaro.org, vincent.abriou@st.com, airlied@linux.ie Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [v1] gpu: drm: sti: sti_vtac:- Handle return NULL error from devm_ioremap_nocache Date: Wed, 21 Dec 2016 10:52:35 +0530 Message-Id: <1482297755-4620-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Here, If devm_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/gpu/drm/sti/sti_vtac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/sti/sti_vtac.c b/drivers/gpu/drm/sti/sti_vtac.c index cf7fe8a..dd749e9 100644 --- a/drivers/gpu/drm/sti/sti_vtac.c +++ b/drivers/gpu/drm/sti/sti_vtac.c @@ -191,6 +191,10 @@ static int sti_vtac_probe(struct platform_device *pdev) if (res) { vtac->phy_regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); + if (!vtac->phy_regs) { + DRM_ERROR("failed to remap I/O memory\n"); + return -ENOMEM; + } sti_vtac_tx_set_config(vtac); } else { -- 1.7.9.5