Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp484098ybl; Tue, 28 Jan 2020 06:40:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxnLJplR3KyReEtfSxY43d6Pf/uiS0SCs18m76Q5SvMrn6BP8qwf96wIfnEidQ0s+02nD6G X-Received: by 2002:a9d:7305:: with SMTP id e5mr15974267otk.64.1580222438230; Tue, 28 Jan 2020 06:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222438; cv=none; d=google.com; s=arc-20160816; b=0dJE6GJn5nTP+GoAKXVrHdkaYSf/EoBxuNJcn0FOsIQo3pT3a+VmRWs47uI0KKhFbh 1UcYMb+2e9Nj7fdOLTKp1iVJWJWFrsqukpYmKn1I7ZaI+yecxe3b1w0Dx5XuTdrGEsje kswtv/jPfyH2NX/rFJE6/npbJTFyg+Q7YN8gctRdzXF2ltU5eFG5TXKCLRD5cHhYjjQg DbDjSxsAowPue/GRO/AC+s1Qx+l0g/G/UG5Br9+C/pFrFiGSDYkpQUuAz5VvCofyWdvM 0MKvKKMk7LDrwlMFdn1rzVQ3y9dza1D+9UDCg4ZZ40MUsVxUwRd3yDzPK4vp4agGWFiX 7g0Q== 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=D4q+rH9jOX5U6d8croR9KQjuIxpDtGo2uK0JvtCUwFY=; b=ir1FYL8RNNyykBIeVVKZSOanv0g3lpJzKOsKeWSFe+Vl0hNGuoZkSKLoOE8K67+dME 1Sp4iBUJyJAfQX3u77TcoYimtz8OGkKI+srqtClEW8ErOX8ek33x04591YXzqSAg4/bs GYgwbOcmVkkGojMUzMzJGK1xTsqjpzWS5Um8KAh33jjF9EEUdonnCc2AqUCXqeYG01TL RebFH7tMQ9PoMydm21o8z3qExNV6y1GkzuW8IZ/UWT6guLNZyVwEQ7kHsZ855C+URQ+P hMrIJdMKc2pgnYvE1hB6ANLnkQuckiukEm+Ato1hkV+0SUOxBQvtJ7/1KtKeqoFvUxY+ joDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdfxLvyo; 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 d2si4563187ote.9.2020.01.28.06.40.26; Tue, 28 Jan 2020 06:40:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=RdfxLvyo; 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 S1730704AbgA1Oiu (ORCPT + 99 others); Tue, 28 Jan 2020 09:38:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:42032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729903AbgA1OSH (ORCPT ); Tue, 28 Jan 2020 09:18:07 -0500 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 960D021739; Tue, 28 Jan 2020 14:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221087; bh=PcEUpSz1l1Agv5M26s4TsmTinViyWnuAaUguPsE67hI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdfxLvyo5ydQ1MqRABImDWxb/WVijjgwbJ8c6USlokFbO283lbCsPdus39K6hdbUp nx+xVxNXTZ7S7kv4r1LQfWZkNdkV/ZIXhVhsO9JZDyF2qQ3VMhuJtGHRj9XBIOhZt9 8hdYyndMyTuREJzdfEJoAGoucE1Z+Wczf9NmQF7s= 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.9 084/271] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of() Date: Tue, 28 Jan 2020 15:03:53 +0100 Message-Id: <20200128135858.823917481@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Takashi Iwai [ Upstream commit 8d1667200850f8753c0265fa4bd25c9a6e5f94ce ] The apq8016 driver leaves the of-node refcount at aborting from the loop of for_each_child_of_node() in the error path. Not only the iterator node of for_each_child_of_node(), the children nodes referred from it for codec and cpu have to be properly unreferenced. Fixes: bdb052e81f62 ("ASoC: qcom: add apq8016 sound card support") Cc: Patrick Lai Cc: Banajit Goswami Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/qcom/apq8016_sbc.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index 07f91e918b234..754742018515a 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -114,13 +114,15 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) if (!cpu || !codec) { dev_err(dev, "Can't find cpu/codec DT node\n"); - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto error; } link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); if (!link->cpu_of_node) { dev_err(card->dev, "error getting cpu phandle\n"); - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto error; } link->codec_of_node = of_parse_phandle(codec, "sound-dai", 0); @@ -132,28 +134,37 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); if (ret) { dev_err(card->dev, "error getting cpu dai name\n"); - return ERR_PTR(ret); + goto error; } ret = snd_soc_of_get_dai_name(codec, &link->codec_dai_name); if (ret) { dev_err(card->dev, "error getting codec dai name\n"); - return ERR_PTR(ret); + goto error; } link->platform_of_node = link->cpu_of_node; ret = of_property_read_string(np, "link-name", &link->name); if (ret) { dev_err(card->dev, "error getting codec dai_link name\n"); - return ERR_PTR(ret); + goto error; } link->stream_name = link->name; link->init = apq8016_sbc_dai_init; link++; + + of_node_put(cpu); + of_node_put(codec); } return data; + + error: + of_node_put(np); + of_node_put(cpu); + of_node_put(codec); + return ERR_PTR(ret); } static const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = { -- 2.20.1