Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2514327imm; Mon, 24 Sep 2018 05:45:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60t9Zu2Ro9tqxLcfFWe+bdptf7pc4MySFhkpY76usfUj1cKveADPzMTUj3KHdQzSBc+Z1pT X-Received: by 2002:a63:2020:: with SMTP id g32-v6mr1229352pgg.235.1537793128619; Mon, 24 Sep 2018 05:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793128; cv=none; d=google.com; s=arc-20160816; b=pd2HJif0UrThcvOgqgckisFMWATizq9nXBx70Ij4aFHEgmWX1G5xnr+pW24B0LBU8r LuCVLNg7jAZokjT+6tQBdxSNKzdpypNKm4ilAAc8/vv318vHz+S9R5y4MXSgpBSfg3tJ 9fn4MoMxt2KZWjA+jGZX17HD1HGnpPuU2OcT81b3I8ULyMXnoTYCg1TNFfrTRnBkZDMv jOakBxWuorGV1QYi8JhbP0wdNKJ6SANs+MS48SkqiaHTbprxDpnuKiVgWq/PMpwoG1Cm a7aokoAVNtEK+Kdm2lmURQm/89S2sTHq5EcZVkYem18HB7DMa+npNPk+sUpIkG+etfDb ejgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Ck0a1qnzwPfU5ig2XzXGwq5zgLfto9GH1J9aDpIdcQ4=; b=UW7zAXgXAmbjKdo8DS0U15V8fIbPaS9nQ5jF7BYpZPmUVAIbLKEIV11jKrmY0c7rdh LClxGZdXC24mFLcdXtMDjj99hB2z74WJJa3muuV7+X5ANUgeVFiMvS7oHmKsnjwWF+Yt tVXejTviT+SWqF0zRCrCl1IYH8BO49Nr12lEJ4oRgQCnIEdAYE8Bx3nZCiRW0BqvWIT5 MTATfpN/ef3RzKaRFAlJzC40JB4wTBMmBkAsu9VDg6cVIY5Il2TfDOzaJTaEKqDkAxB3 FFW214xr61bh5BA0uSXLnk+r5a3DlCcsNYRJqD19qoWONZybMqFCu4oHY2b8lCTuTKXo FE3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si31780196pgq.240.2018.09.24.05.45.12; Mon, 24 Sep 2018 05:45:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389114AbeIXSqJ (ORCPT + 99 others); Mon, 24 Sep 2018 14:46:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59558 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387512AbeIXSqJ (ORCPT ); Mon, 24 Sep 2018 14:46:09 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 22642109A; Mon, 24 Sep 2018 12:44:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Wei Xu , Sasha Levin Subject: [PATCH 4.18 173/235] ARM: hisi: check of_iomap and fix missing of_node_put Date: Mon, 24 Sep 2018 13:52:39 +0200 Message-Id: <20180924113122.144624231@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-hisi/hotplug.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -180,11 +180,15 @@ static bool hix5hd2_hotplug_init(void) struct device_node *np; np = of_find_compatible_node(NULL, NULL, "hisilicon,cpuctrl"); - if (np) { - ctrl_base = of_iomap(np, 0); - return true; - } - return false; + if (!np) + return false; + + ctrl_base = of_iomap(np, 0); + of_node_put(np); + if (!ctrl_base) + return false; + + return true; } void hix5hd2_set_cpu(int cpu, bool enable)