From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbdKHUw6 (ORCPT ); Wed, 8 Nov 2017 15:52:58 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:34037 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752745AbdKHUwv (ORCPT ); Wed, 8 Nov 2017 15:52:51 -0500 X-Host: mariner.tdc.vzwcorp.com From: "Levin, Alexander (Sasha Levin)" To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Arvind Yadav , "Levin, Alexander (Sasha Levin)" Subject: [PATCH AUTOSEL for-4.4 10/39] drm/sti: sti_vtg: Handle return NULL error from devm_ioremap_nocache Thread-Topic: [PATCH AUTOSEL for-4.4 10/39] drm/sti: sti_vtg: Handle return NULL error from devm_ioremap_nocache Thread-Index: AQHTWNM6Kh3qaIl62UKLpbVxk+0wGQ== Date: Wed, 8 Nov 2017 20:50:36 +0000 Message-ID: <20171108205027.27525-10-alexander.levin@verizon.com> References: <20171108205027.27525-1-alexander.levin@verizon.com> In-Reply-To: <20171108205027.27525-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vA8Kr1k0003401 From: Arvind Yadav [ Upstream commit 1ae0d5af347df224a6e76334683f13a96d915a44 ] 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 Acked-by: Vincent Abriou Signed-off-by: Sasha Levin --- drivers/gpu/drm/sti/sti_vtg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c index d56630c60039..117a2f52fb4e 100644 --- a/drivers/gpu/drm/sti/sti_vtg.c +++ b/drivers/gpu/drm/sti/sti_vtg.c @@ -346,6 +346,10 @@ static int vtg_probe(struct platform_device *pdev) return -ENOMEM; } vtg->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); + if (!vtg->regs) { + DRM_ERROR("failed to remap I/O memory\n"); + return -ENOMEM; + } np = of_parse_phandle(pdev->dev.of_node, "st,slave", 0); if (np) { -- 2.11.0