Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2982902imu; Sun, 9 Dec 2018 14:15:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/UbsuSJvdWfSx0EG7e2Hnw6RvhLeJTXZf4vP4npSSCchtHEGk/Dpo2NoUN5NvVeitfw6Bz+ X-Received: by 2002:a62:9111:: with SMTP id l17mr10082478pfe.200.1544393731898; Sun, 09 Dec 2018 14:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393731; cv=none; d=google.com; s=arc-20160816; b=mHIW80yTCmgE3Per1tBh+C+HXMiRLqp4Xk4wO3nPmnoHVONS0sVHFierPaQyBj51S/ WcIdAdtkhGoN95J8py/5axld0O1FICe8E951hIu43sxnatmzzIA9XBA4lWB9JuKEKHuk HR+ZGkcjgUPyErn6YBf+uUULG3jrdWG2Ui6E69skped2Si9k62U7RaomOdUy5FJpyAJn 7pM+HhKQF0LERvS0H1x67jlfFnkYsJJiQcTUuCEj1ucOia3YnsLJrsg5Ud59j0ASaLy4 VgQg7tcGcy+/Mb3rBBFgnjCa3Cw4ka+1ieC4CqPLIdjOxu4gczpovOR+h0rcneSJ8tXs iXmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=/Ft9mWeRPuYXXtZFFcrhHvWKrcHsBdrHMbnh8VydKf4=; b=bdwMfiUuWXJI3uz3J4JidGl1Ch+uyYBH6PpK4aFhVPavJU5QgN7SCUWhKF4nfhEaiV 4SvQb/1CSQkhUqudpOPb5xoPJJ1EvQsJNtSsV4HihewFx0IDI8/FReOv7vDmKYNvmH7K lB1JIo637qPO5VGYyg1d+F5zlVyrzYZlUMxsM9os//jof9gochktm34eemUJiwXHmogo GZZelZ3he9hYHc/l2JA4Qco4kRX0/76JtXMjnRUrvFjd5C4KcR7kT9FXeVYUyjv6WtMs n4OGb3q+U6Sc5b1xevHzPvHmhpQIZmXuNB67khuma/3OntOgyy1ocIJLNUkP1H04y/L5 ThpQ== 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 b5si8706217pfg.121.2018.12.09.14.15.16; Sun, 09 Dec 2018 14:15:31 -0800 (PST) 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 S1728476AbeLIWN5 (ORCPT + 99 others); Sun, 9 Dec 2018 17:13:57 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37992 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728206AbeLIWN4 (ORCPT ); Sun, 9 Dec 2018 17:13:56 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73P-0002ic-Eh; Sun, 09 Dec 2018 21:55:59 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72Z-0003FT-Gc; Sun, 09 Dec 2018 21:55:07 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Nicholas Mc Guire" , "Wei Xu" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 042/328] ARM: hisi: handle of_iomap and fix missing of_node_put In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Nicholas Mc Guire commit d396cb185c0337aae5664b250cdd9a73f6eb1503 upstream. Relying on an unchecked of_iomap() which can return NULL is problematic here, an explicit check seems mandatory. Also the call to of_find_compatible_node() returns a device node with refcount incremented therefor an explicit of_node_put() is needed here. Signed-off-by: Nicholas Mc Guire Fixes: commit 22bae4290457 ("ARM: hi3xxx: add hotplug support") Signed-off-by: Wei Xu Signed-off-by: Ben Hutchings --- arch/arm/mach-hisi/hotplug.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/arch/arm/mach-hisi/hotplug.c +++ b/arch/arm/mach-hisi/hotplug.c @@ -137,13 +137,20 @@ static int hi3xxx_hotplug_init(void) struct device_node *node; node = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl"); - if (node) { - ctrl_base = of_iomap(node, 0); - id = HI3620_CTRL; - return 0; + if (!node) { + id = ERROR_CTRL; + return -ENOENT; } - id = ERROR_CTRL; - return -ENOENT; + + ctrl_base = of_iomap(node, 0); + of_node_put(node); + if (!ctrl_base) { + id = ERROR_CTRL; + return -ENOMEM; + } + + id = HI3620_CTRL; + return 0; } void hi3xxx_set_cpu(int cpu, bool enable)