Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5596490img; Wed, 27 Mar 2019 11:22:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYf+afg1tszdg/hTfkhhqToj7sAmGQmGyvLX5Z/+E2QhyhtWY5jhw4Rm7Hi1EShANWLkv1 X-Received: by 2002:a63:2b82:: with SMTP id r124mr35367722pgr.214.1553710953134; Wed, 27 Mar 2019 11:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710953; cv=none; d=google.com; s=arc-20160816; b=LvkRS8KZMdJSeEV13W1ekWNmNUARzCt2nkBxbF/12fnIxDFdL0TFR4NUnTKk9mPLr4 Hp/pf/d+HGWSMYoOcgaX5bcvaJQPOH1aaJonojF5J7HDEv7zvviSylCWTZ2k7D8Bofo4 /4HxoUw/azb3csRyMK8qAsx4aJkZxzxRgF40e4EfTeA4Gy85Eavs4zpelM4Qy7IUcm/d CtqDZADiK0GEIgztcxspGqpvuL3fUboqYJxBlciB4LrvwW/Qyp70aDP3L1Ldqyu8kU2P 1oshZGIlF6z/ow21hUioTTP7KdqoqWHtewMAlCC1oAM619N8ZfGJpWkSF4lNJPsJGbLG Jrrw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mJ/qS54Lvi4Rok7RfUan38Ixf/QYZD6VrIkiEygkCss=; b=jbFT+hZ8pbZtG4ovwXvgpOojDZzNfonqfCMc3ei45ttAzgVXlTeXgEpT6hmQlQzJSu BMf0dAFEHS4MH5jf9fUtF9q5y5nN8qb8jSX0MtrWYY34rCNQPx4erz9rPKLU/rpl/cjP 5SaMWEV5PfbJsAQZBmY5feSgISBBFyZIj2C374rctjZccBiXQqRGE4pAdG9ylnPIK9YA pkc0ngRPvD/jxNCT+DxQzppQxwFzAXg870BuDStNweCpHY6g+nqmXVVnmOT/zh1pPFjy s4azN1OfL9guNw793yLV535DUnGW+/E1eE+yvtAcZHPB/m4xoAcF1qjRHTp7mJNtzyPQ f+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OKpyHpcp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2554984pgb.435.2019.03.27.11.22.17; Wed, 27 Mar 2019 11:22: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=OKpyHpcp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390903AbfC0SVm (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391212AbfC0SVi (ORCPT ); Wed, 27 Mar 2019 14:21:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 129B92087C; Wed, 27 Mar 2019 18:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710897; bh=hA1EA4E8n/ipPxwcO4eDjpYs9zDg611IJg7EcKT+weQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OKpyHpcpWqP5tBeUiaAQp9QfqFH/CShhUc2WU71ItjPVxZNsQWwTl34gryRz0JiyA n6iuvyCRzdJ8uVCIgeub8ujQaFCB0kg6tvHAQ6IW3dNVoTtCjYYNavqow1scNQO1TX eMvgU9leuKs8LSPDNrNIi9UgkCdCQwgmn62/k0aU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Patrick Lai , Banajit Goswami , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.9 35/87] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of() Date: Wed, 27 Mar 2019 14:19:48 -0400 Message-Id: <20190327182040.17444-35-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore 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 07f91e918b23..754742018515 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.19.1