From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0097.outbound.protection.outlook.com ([104.47.32.97]:53808 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729303AbeIOGxC (ORCPT ); Sat, 15 Sep 2018 02:53:02 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Zhouyang Jia , Alexandre Belloni , Sasha Levin Subject: [PATCH AUTOSEL 3.18 08/11] rtc: bq4802: add error handling for devm_ioremap Date: Sat, 15 Sep 2018 01:35:29 +0000 Message-ID: <20180915013521.180178-8-alexander.levin@microsoft.com> References: <20180915013521.180178-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013521.180178-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Zhouyang Jia [ Upstream commit 7874b919866ba91bac253fa219d3d4c82bb944df ] When devm_ioremap fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling devm_ioremap. Signed-off-by: Zhouyang Jia Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-bq4802.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index fc0ff87aa5df..f53198207e93 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c @@ -164,6 +164,10 @@ static int bq4802_probe(struct platform_device *pdev) } else if (p->r->flags & IORESOURCE_MEM) { p->regs =3D devm_ioremap(&pdev->dev, p->r->start, resource_size(p->r)); + if (!p->regs){ + err =3D -ENOMEM; + goto out; + } p->read =3D bq4802_read_mem; p->write =3D bq4802_write_mem; } else { --=20 2.17.1