Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp998330yba; Thu, 4 Apr 2019 02:05:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmV0g09HOzS5rZnaFu7YtLwdPeZohIaQCzk2QL3MxDjiG3NQTpw6yHAKFHwSP0Owvn626w X-Received: by 2002:a62:174c:: with SMTP id 73mr4653049pfx.33.1554368699921; Thu, 04 Apr 2019 02:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368699; cv=none; d=google.com; s=arc-20160816; b=Qb789QUOOe1oS/GQ/RTeI4dJBlNXOMd+fv5/0XCd7EtyHyaDNEy3U6IEz1oyUdkxoO zp96yKj6Q9gtHJzPhVQ1P8uoAF0qVPHq3sVfte/CUVJ+5xzOskOg9hChnwS8crnfu3tQ +w7/KnM1Py9c3iADgVaQ1l8tZrmXRiCskmZc/oxrkEV+bv3LVo0OumxyySo50+eP4WeB yhZaDglqnyfeX+4ECo0qS212FnsSjy5lQ8w6BlfuZXRqlT6vnPlo7aLqcV6/hWPFJuxg Cen7B+niwMYWDsy2d4E4HBecrUux2lqIJu/BoF8faPjgZjRP0lYg5KFgrnrMBr497LFw msAg== 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=dOeJneRJKuavqesgkhuvGSu1iPMKGTzsU6ceXYHWdtk=; b=FQl11T6ARg/uO0JXQIDL6fZ6tsG9kR9yCYz1wRlWY2QB1E3XyBi0ImyVA1EVEnA4kD OmjJeHWrGYfh8L845eY8/e9lhwf8iMqnApTHBo4rHi+cyvc4uzDwQBfPlTuNKRO8EB+i W6wtDMqe/e2jj0T+3AYxV4xGNm4I90s3t4xxislZgmYmZXKCIkxJk8QFt22hHWEFfYi6 8hwx7FXGXVca2OuwA7P6fpOeOjt/9f1zD60WiRqZXwsaoaHvHJovZ9eY2OseRQkQHeq0 OgJwwFF8iJ++5KNgy59PMMnb1GJjXRCYU2WbHKReJw7b2DgE9cgERcsDfyTRptHsi9Q3 WBuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IBQLvPLR; 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 b6si15152722pgw.70.2019.04.04.02.04.44; Thu, 04 Apr 2019 02:04: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; dkim=pass header.i=@kernel.org header.s=default header.b=IBQLvPLR; 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 S1731710AbfDDJC5 (ORCPT + 99 others); Thu, 4 Apr 2019 05:02:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:40488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731706AbfDDJCy (ORCPT ); Thu, 4 Apr 2019 05:02:54 -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 3EC322177E; Thu, 4 Apr 2019 09:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368573; bh=+1KlLDM8bPlxwxjTFr8APLBnXvi87mEFfJbc9S1ue+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBQLvPLRObtFPJOF1x6YT92HJLOQ1jl4qclBQW8LK6fKpMxa7+WUroQj26aEV59BB 7rjpoknzicwFsFVTzhwUPd5chIv1jjtJvh3XAA0tFYIG5gTbOrhomaH0UP9kzR+5zR kThtgim2yOkvxcevPVRvA0c1VgRtUpTB2xYOesAE= 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 4.19 073/187] ASoC: qcom: Fix of-node refcount unbalance in qcom_snd_parse_of() Date: Thu, 4 Apr 2019 10:46:50 +0200 Message-Id: <20190404084606.489340270@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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 4.19-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