Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp958946pxa; Wed, 19 Aug 2020 21:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF6uHR7D2Wp5IolVGKgngyb/x6sdALyxa+JQQGdf3XO4bGICPifRwx32TCL9NwAwf/SWUW X-Received: by 2002:a05:6402:1a23:: with SMTP id be3mr1235576edb.138.1597897809563; Wed, 19 Aug 2020 21:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597897809; cv=none; d=google.com; s=arc-20160816; b=SxBwsdOODXowhpCaxTaPNbumLM4hjryCO+UA8jLwkkqMDMSkhYiRodMeb5TgHCUwyX gloc9VL8dNdiC++ii9all/2pxazWIQcpAHrVMgCAOkPknVXmyrL0vzXtt2ksLrK2AN4h CwOmZpKaXMOGJlIOx/8TJfq5bJve1GaJyfVyix8x9e1nYI1/boA0yjPWk2XFlKkoPqOk Kl9iaCI5PhDywBSq9izaqlDsh/0Fi5D898lKSAsYFBxC0ps3CFWvhMk1KLQAmjIZpREQ UFquoAcy1fomqapNK0Uat5NMrSCaFzJ4wscpihoeWHJdWcty9H1zyU4H12KwYZfFNUfV D4tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=wbMZD+SC5PQS7BVdoxo65UP1shf417DIWhDUYY1KLOg=; b=G44mJ2quZDtLGaJBCYH/0/boRN04I0Fx9NpkbGlcoef7i5tAcz7Ed8+eVrMLMIfdA9 KWLJiBdPCSacdk2Jy9sFsZ1CbC3+0XJMzAbdxJSty7NwDAm0b7HplTcvrdG3QIMNhzCG j76fjl/kYvrC39AEbTNwlY/7qhQXpfkQtscLnKZuwC7Vze5dTJ90VXgqtG8os3uRnRpm IqPTT3hShdPvE96nVTzYef/xkhiQy+PMfZHW+gUnv3QyJUxaiUqt13EBdk5K5Wyy+e0Q g4UqysQGViP+BFqnqIdqgs07+WX1iCIGp5F7wrZ70mIB8RQpTQwIL1GUjctQ0pAdHAH4 BG7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs7si503580ejb.165.2020.08.19.21.29.44; Wed, 19 Aug 2020 21:30:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725793AbgHTE3J (ORCPT + 99 others); Thu, 20 Aug 2020 00:29:09 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:32464 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725770AbgHTE3I (ORCPT ); Thu, 20 Aug 2020 00:29:08 -0400 Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app2 (Coremail) with SMTP id by_KCgD3_rLs+z1f6KMHAg--.11144S4; Thu, 20 Aug 2020 12:28:32 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Patrick Lai , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Bjorn Andersson , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: qcom: common: Fix refcount imbalance on error Date: Thu, 20 Aug 2020 12:28:27 +0800 Message-Id: <20200820042828.10308-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgD3_rLs+z1f6KMHAg--.11144S4 X-Coremail-Antispam: 1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fo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgoSBlZdtPnBhAAJsW Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org for_each_child_of_node returns a node pointer np with refcount incremented. So when devm_kzalloc fails, a pairing refcount decrement is needed to keep np's refcount balanced. Fixes: 16395ceee11f8 ("ASoC: qcom: common: Fix NULL pointer in of parser") Signed-off-by: Dinghao Liu --- sound/soc/qcom/common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c index 5194d90ddb96..fd69cf8b1f23 100644 --- a/sound/soc/qcom/common.c +++ b/sound/soc/qcom/common.c @@ -52,8 +52,10 @@ int qcom_snd_parse_of(struct snd_soc_card *card) for_each_child_of_node(dev->of_node, np) { dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL); - if (!dlc) - return -ENOMEM; + if (!dlc) { + ret = -ENOMEM; + goto err; + } link->cpus = &dlc[0]; link->platforms = &dlc[1]; -- 2.17.1