Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1478143imm; Thu, 12 Jul 2018 02:34:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcTY4gJafvD/qvdtjDUG/FBXnAmQntEstBDizvXHErN2OJ/RYnekGrf0BZKPT0UbTrRaKBf X-Received: by 2002:a65:5803:: with SMTP id g3-v6mr1412862pgr.117.1531388099114; Thu, 12 Jul 2018 02:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531388099; cv=none; d=google.com; s=arc-20160816; b=KduYbyV/2U9IYTpxDNuFsBjVzLxFue/mHnKKdiybuMqS9pPZwIEm4LFsryHRiJjWz2 t4GLebadBiRH7L4Df3K5BDzbnJ71DVhsvoUeMNDhXrCJuxplUZ/59WkBlH+jVqUAj3qI xeT4Q1J7y6caZCsUOaqGWCUkdW3Qh/MbUTaen1sl0kptWR152XjaZhBpt4D1aHVYYtFW xXW+lam1s3Q0nroI6xa81VUVneBlHVWc6HQ8+lC4M0GHQjzFWtgTHrkkWmKW3/7xfbhO SpLfFS7Mm3VNbkUOngfUusAOtDIgvUWBPsdbM7UuQM5PwAW8Srb/nzrEYsSy3aqsk3nY LdPA== 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:arc-authentication-results; bh=jdqXAjocWP2f66RFCq9qxqSxmCHhzAlltyPWx3+X0UM=; b=NwbkH2zPy/4DioW7dCgfrC50QmTScqCvzMqK/su1+VErTLhFWckZwRBWF/OobPLHC4 +SaLlrqiE2SzjBEYj3cGqJ9IDaphDZnWfwjwJCHwbc06EDG+cQWv7GlvyQYlSG9fTB57 S1sqTE6BSjfFhRe090sG/JrezwxIFGrGmadgMz1wIEskp7+XL4/kbuOIAoS6mk9gL9Mz SG6LCdPSxRBT2wAGCWzXf7kX11095qjm0dJGVvZ/ShSrXM2zlQZDni3QdCa09LrDBg8J 3EvwAJTnhDz9nNUrPo0o9tjT7pcGGH5rwM3qI24aHNO2jfWgAcCregq2YfgJagykiTmn M21A== 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 z63-v6si22523254pfi.214.2018.07.12.02.34.43; Thu, 12 Jul 2018 02:34:59 -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 S1726786AbeGLJml (ORCPT + 99 others); Thu, 12 Jul 2018 05:42:41 -0400 Received: from www.osadl.org ([62.245.132.105]:42766 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeGLJmk (ORCPT ); Thu, 12 Jul 2018 05:42:40 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w6C9T86L021688; Thu, 12 Jul 2018 11:29:19 +0200 From: Nicholas Mc Guire To: Wei Xu Cc: Wang Long , Haifeng Yan , Russell King , 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: Thu, 12 Jul 2018 11:28:23 +0200 Message-Id: <1531387704-13265-3-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1531387704-13265-1-git-send-email-hofrat@osadl.org> References: <1531387704-13265-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=0.4 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q autolearn=no 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