Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2502191imm; Mon, 24 Sep 2018 05:33:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaGgE2QxxqRD8oXasEMuKgw5K38UOVMXO8zzajiYMUmDNESIJUg0v6kQkDxqajUkSQOVugk X-Received: by 2002:a62:c082:: with SMTP id g2-v6mr10227614pfk.72.1537792414604; Mon, 24 Sep 2018 05:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792414; cv=none; d=google.com; s=arc-20160816; b=iQgN1VYslD1fljs8ONhLWK+53TGA+BGhbun6dGlcrnmYVJPBH2u0gFoKu1KsH+a7sp DRFoUbW2FK9oJBVxzuBUR9uEU30FW+bpZbXCD3/6yAiZhcEHSOYUmRLtv7U5Ni8XS/hI TJR07ed/rbfCdxdGcXpFQflwgrL0LBbVbCC7tLwAMeuQ1tBVAiKh5Mp1LMwdjOyncKLY pbz8pck18qCmRE3pffACZnBCwaRQ0DF6rIIGmphWNUI++lAqJVrJ5N7EmYNsO04202Be g4xKTCHikZTD9qtNiAW0q6qFKRR6/IGN/4EQ6Aasw+hrbZYKW5hbpdtuUUGO7XWEJHaA p1qw== 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=oQ7jJwARz1NpBNPnmefz58sx2i9Lot0mNF5HGqz1YgI=; b=V9OaKOeDCeIX5d1h6J8QtZfIbeaiB9bt8XHa6sGreLfFIU5c1bcULzB6eswrqv9uf7 NeIXC9V+E0ZcVm+O+U6zFVfPTAA5gPzRNX3c6P2rh3ngwBKhI3VnrOK/M2dJJPcv5pP9 Ilw1bV4pUKkgbZuddbDu8mhrGymQqShDyQeA8UGfSpehj7eO32szYrGV7ieghZH/8YoY CyNSCj/bDJJ4ohGZhJLgSyGkL+7YEeWRZA3hGCwbiSxXpEQsAesCDEmGo2DlXQKdPa1D Feds3grmH0kgYh7o04HvRwxE6dDAaWp4ArWLmKlozUXS24IgdVZDcJbDCYlzM+G9vSGI a/AA== 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 f9-v6si31521pgk.594.2018.09.24.05.33.19; Mon, 24 Sep 2018 05:33:34 -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 S2388144AbeIXSeN (ORCPT + 99 others); Mon, 24 Sep 2018 14:34:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58116 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730184AbeIXSeN (ORCPT ); Mon, 24 Sep 2018 14:34:13 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2B20E1018; Mon, 24 Sep 2018 12:32:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Mark Brown , Sasha Levin Subject: [PATCH 4.18 090/235] regulator: qcom_spmi: Fix warning Bad of_node_put() Date: Mon, 24 Sep 2018 13:51:16 +0200 Message-Id: <20180924113114.123061855@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: Niklas Cassel [ Upstream commit fffe7f52eb5db41eedadba9a8038e982dcfaee0c ] For of_find_node_by_name(), you typically pass what the previous call returned. Therefore, of_find_node_by_name() increases the refcount of the returned node, and decreases the refcount of the node passed as the first argument. of_find_node_by_name() is incorrectly used, and produces a warning. Fix the warning by using the more suitable function of_get_child_by_name(). Also add a missing of_node_put() for the returned value, since this was previously being leaked. OF: ERROR: Bad of_node_put() on /soc/qcom,spmi@400f000/pmic@3/regulators CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.18.0-rc4-00223-gefd7b360b70e #12 Hardware name: Qualcomm Technologies, Inc. DB820c (DT) Call trace: dump_backtrace+0x0/0x1a8 show_stack+0x14/0x20 dump_stack+0x90/0xb4 of_node_release+0x74/0x78 kobject_put+0x90/0x1f0 of_node_put+0x14/0x20 of_find_node_by_name+0x80/0xd8 qcom_spmi_regulator_probe+0x30c/0x508 Fixes: 0caecaa87202 ("regulator: qcom_spmi: Add support for SAW") Signed-off-by: Niklas Cassel Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/regulator/qcom_spmi-regulator.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) --- a/drivers/regulator/qcom_spmi-regulator.c +++ b/drivers/regulator/qcom_spmi-regulator.c @@ -1752,7 +1752,8 @@ static int qcom_spmi_regulator_probe(str const char *name; struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; - struct device_node *syscon; + struct device_node *syscon, *reg_node; + struct property *reg_prop; int ret, lenp; struct list_head *vreg_list; @@ -1780,10 +1781,13 @@ static int qcom_spmi_regulator_probe(str for (reg = match->data; reg->name; reg++) { - if (saw_regmap && \ - of_find_property(of_find_node_by_name(node, reg->name), \ - "qcom,saw-slave", &lenp)) { - continue; + if (saw_regmap) { + reg_node = of_get_child_by_name(node, reg->name); + reg_prop = of_find_property(reg_node, "qcom,saw-slave", + &lenp); + of_node_put(reg_node); + if (reg_prop) + continue; } vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); @@ -1816,13 +1820,17 @@ static int qcom_spmi_regulator_probe(str if (ret) continue; - if (saw_regmap && \ - of_find_property(of_find_node_by_name(node, reg->name), \ - "qcom,saw-leader", &lenp)) { - spmi_saw_ops = *(vreg->desc.ops); - spmi_saw_ops.set_voltage_sel = \ - spmi_regulator_saw_set_voltage; - vreg->desc.ops = &spmi_saw_ops; + if (saw_regmap) { + reg_node = of_get_child_by_name(node, reg->name); + reg_prop = of_find_property(reg_node, "qcom,saw-leader", + &lenp); + of_node_put(reg_node); + if (reg_prop) { + spmi_saw_ops = *(vreg->desc.ops); + spmi_saw_ops.set_voltage_sel = + spmi_regulator_saw_set_voltage; + vreg->desc.ops = &spmi_saw_ops; + } } config.dev = dev;