Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1016017yba; Thu, 4 Apr 2019 02:29:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHypnk1c42NNpi9GYKpTPgWOKIYbI6mrqBvLsEnDxcWtutrodaPutztcCX5Vkom62rqlgd X-Received: by 2002:a63:1548:: with SMTP id 8mr4435426pgv.277.1554370173717; Thu, 04 Apr 2019 02:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370173; cv=none; d=google.com; s=arc-20160816; b=P1LcblJQSW3/UKGJ4TQWkrGZb8Fjkgxfh4/+eKS1Py9XOb66XBVWL2O7S3gvOxXpgp bDbHYlm4QOqKgScP9TVCaRhysmOUxoVbJkk+Kt5jT2YoQfEOAJbW+F8TaCFNKTmFWe2c Nyl2mSKY5xoa8+JeULyYIa+qW6QBtlpcgck0pxLW81wmb1PukmcAYKGlytCT4AFL0HPE s1NfRMz8PeaqraXULuxTaP+rUyQPQw+5aUbzgcFEd5ZzW4/7W9IXJzfOfxX+FL0Jzh7m eB6mmAaD2dtlVlckBRZYlps6G+VM3i+hwf9Y+89SdtRzH2v6HwjitBWC3LXkZVV0g89O FmMw== 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:dkim-signature; bh=EGriG0PpLFZmfeUAVrq6/igYwc8GXGaYCcqbI42Yn60=; b=pp385hBjIrzy4eZUXzfz/EZGeYFe9pJw8eoAU8UHpQohyalHc3cRr1+yfFSK0NOPfL Cb2Op0sdywekldsRACFvBA9zebrl1gNFVLLC37ubV2UxYcWOry9k88OXR7h8gup3F9ov mVDWmsPNBqxS3xu1pCtjmyTQU/thUInqRVLltx6MBDyMxP+7jNYhAZP8QP59i2AI4eTS Ak+nkw49FIKw1KAlOjs7W+Y4LqtcDGbPH/FKMqpJRKZw6P0bJT5dj0j1rwsSfnhUYV8T 3GZAyopWvYwCxlb4NJLq/g/8rDLweMv9JfKHYUzZYr9fAxxrxEWZCNO7vb2IScwThm5t 3Niw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gQ91joqM; 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 z6si15536294plo.372.2019.04.04.02.29.18; Thu, 04 Apr 2019 02:29:33 -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; dkim=pass header.i=@kernel.org header.s=default header.b=gQ91joqM; 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 S2387409AbfDDJ1c (ORCPT + 99 others); Thu, 4 Apr 2019 05:27:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387402AbfDDJM1 (ORCPT ); Thu, 4 Apr 2019 05:12:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69F3A2054F; Thu, 4 Apr 2019 09:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369146; bh=OFAh3dGBaov2BiMnfz6SNoTC4cw2zy7+8Cm+bWNGtoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gQ91joqMoTtt7UDReBtQzkFsrndDVD57DDBZMzAqzDLAKsLTxTbScTDmS4oKbz+E0 rcLpIvKtIQg7AaGVEozBwQqo3+Je1HJaFLVMK6vdrSezxlMkessI3cHMLnx/Rsavzc 8WAOH1hABbh1dqTJFjGoCWHJqwgvXXjENT6FICQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrick Lai , Banajit Goswami , Takashi Iwai , Mark Brown , Sasha Levin Subject: [PATCH 5.0 101/246] ASoC: qcom: Fix of-node refcount unbalance in qcom_snd_parse_of() Date: Thu, 4 Apr 2019 10:46:41 +0200 Message-Id: <20190404084622.681416689@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 70b773219a32c7b8f3e53e041bc023ad99fd81f4 ] Although qcom_snd_parse_of() tries to manage the of-node refcount, there are still a few places that lead to the unblanced refcount in the error code path. Namely, - for_each_child_of_node() needs to unreference the iterator node if aborting the loop in the middle, - cpu, codec and platform node objects have to be unreferenced at each iteration, - platform and codec node objects have to be referred before jumping to the error handling code that unreference them unconditionally. This patch tries to address these by moving the assignment of platform and codec node objects to the beginning of the loop and adding the of_node_put() calls adequately. Fixes: c25e295cd77b ("ASoC: qcom: Add support to parse common audio device nodes") Cc: Patrick Lai Cc: Banajit Goswami Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/qcom/common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c index 4715527054e5..5661025e8cec 100644 --- a/sound/soc/qcom/common.c +++ b/sound/soc/qcom/common.c @@ -42,6 +42,9 @@ int qcom_snd_parse_of(struct snd_soc_card *card) link = card->dai_link; for_each_child_of_node(dev->of_node, np) { cpu = of_get_child_by_name(np, "cpu"); + platform = of_get_child_by_name(np, "platform"); + codec = of_get_child_by_name(np, "codec"); + if (!cpu) { dev_err(dev, "Can't find cpu DT node\n"); ret = -EINVAL; @@ -63,8 +66,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card) goto err; } - platform = of_get_child_by_name(np, "platform"); - codec = of_get_child_by_name(np, "codec"); if (codec && platform) { link->platform_of_node = of_parse_phandle(platform, "sound-dai", @@ -100,10 +101,15 @@ int qcom_snd_parse_of(struct snd_soc_card *card) link->dpcm_capture = 1; link->stream_name = link->name; link++; + + of_node_put(cpu); + of_node_put(codec); + of_node_put(platform); } return 0; err: + of_node_put(np); of_node_put(cpu); of_node_put(codec); of_node_put(platform); -- 2.19.1