Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp280297yba; Sat, 13 Apr 2019 00:24:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYIZrWUD5pP+hdlQAFG5rLw3+wjP1EruQkQuD2TvNKoMQnYkEKmxFWpbo8Z3ubAZNnvMh7 X-Received: by 2002:a65:63d7:: with SMTP id n23mr56820826pgv.26.1555140275166; Sat, 13 Apr 2019 00:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555140275; cv=none; d=google.com; s=arc-20160816; b=RbKAHNZZ1rc8+XudxsmX+gF66W+rWnxwi7V/g0xqfviPlzNhvmXD5InfIYLGSUuhT9 A08dr8x95uRP1kZwkHmYF6UjtJdAwk80Cs7O2XlYCwD2hq5nBd267rq9vpARBRPvyarL 7rgkyc2shf3B8iQAu5uWD+jCDc6xL/pe9bQ4OK7jjxXghDcUgFtFpwddUrdj//Ujv0L1 il1laDTOi3dEGKQzcTmzG4lDGplRWOLlFrCVy6nU79zFdYOwGKaiKPE0rMVh3CAYcR7E R/Djy/n7ZzzJBYCQVyXHAhlnEdamsXc0h9VrSZszAP9s1pGV1JdAYD/uEvAa0fc+G3sA 3XfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=jdqXAjocWP2f66RFCq9qxqSxmCHhzAlltyPWx3+X0UM=; b=G4nBmCxksOGVvIu1P3kdbHPNiBvJ0JAk2DLtQhZ01zRXkgf4sCX1Tcxa2zscz+Il7r MapZLxn1LBynJ2OxtCyG5cHEFQBVUTjSewIWIUa1sYLpOwBBWb+GCazitvsq2pTg8YkC lLwIBCeUI3Az9UGmxay2AO//YnI4txbYu8ac4bWC/TYYDRu0jf5ZLd04WNi9C09SEy6L DZVPErK3mILTD1gZwgQClW67esdLZMwR02z9bFpN2O5uf1XZ2BLoDUJabeuFeO8jgmAn 4cQssDffMoBX1uuPtuYYwwXd2n7/JMI+o3CWiWNjPWIyVMKnPqm4cWi6BNcZhu1SvUcL +SBg== 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 62si22836616pla.124.2019.04.13.00.24.18; Sat, 13 Apr 2019 00:24:35 -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 S1727478AbfDMHV7 (ORCPT + 99 others); Sat, 13 Apr 2019 03:21:59 -0400 Received: from www.osadl.org ([62.245.132.105]:36461 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727112AbfDMHV6 (ORCPT ); Sat, 13 Apr 2019 03:21:58 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x3D7JfAY003435; Sat, 13 Apr 2019 09:20:34 +0200 From: Nicholas Mc Guire To: Russell King Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Mark Brown , Linus Walleij , Tony Lindgren , Mike Rapoport , Janusz Krzysztofik , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH 2/3] ARM: hisi: check of_iomap and fix missing of_node_put Date: Sat, 13 Apr 2019 09:14:22 +0200 Message-Id: <1555139666-948-11-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1555139666-948-1-git-send-email-hofrat@osadl.org> References: <1555139666-948-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- Problem found by an experimental coccinelle script Patch was compile tested with: hisi_defconfig (implies CONFIG_SMP=y) Patch is against 4.18-rc3 (localversion-next is next-20180712) 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 3b0d1c6..40857bf 100644 --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -173,11 +173,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) -- 2.1.4