From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0126.outbound.protection.outlook.com ([104.47.32.126]:8380 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729020AbeIOGwq (ORCPT ); Sat, 15 Sep 2018 02:52:46 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Nicholas Mc Guire , Wei Xu , Sasha Levin Subject: [PATCH AUTOSEL 3.18 06/11] ARM: hisi: check of_iomap and fix missing of_node_put Date: Sat, 15 Sep 2018 01:35:28 +0000 Message-ID: <20180915013521.180178-6-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: Nicholas Mc Guire [ Upstream commit 81646a3d39ef14749301374a3a0b8311384cd412 ] of_find_compatible_node() returns a device node with refcount incremented and thus needs an explicit of_node_put(). Further relying on an unchecked of_iomap() which can return NULL is problematic here, after all ctrl_base is critical enough for hix5hd2_set_cpu() to call BUG() if not available so a check seems mandated here. Signed-off-by: Nicholas Mc Guire 0002 Fixes: commit 06cc5c1d4d73 ("ARM: hisi: enable hix5hd2 SoC") Signed-off-by: Wei Xu Signed-off-by: Sasha Levin --- arch/arm/mach-hisi/hotplug.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-hisi/hotplug.c b/arch/arm/mach-hisi/hotplug.c index 6385abcd321e..f31b4d99b5fb 100644 --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -177,11 +177,15 @@ static bool hix5hd2_hotplug_init(void) struct device_node *np; =20 np =3D of_find_compatible_node(NULL, NULL, "hisilicon,cpuctrl"); - if (np) { - ctrl_base =3D of_iomap(np, 0); - return true; - } - return false; + if (!np) + return false; + + ctrl_base =3D of_iomap(np, 0); + of_node_put(np); + if (!ctrl_base) + return false; + + return true; } =20 void hix5hd2_set_cpu(int cpu, bool enable) --=20 2.17.1