Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1008959pxb; Wed, 6 Apr 2022 06:36:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMTaIxwz3Pah5uoE37rfob7zmM0Fk5Qg30vMfQUALB2NFNenSgovXYgvvDuhkt1qQgiw4I X-Received: by 2002:a05:6870:56a1:b0:e1:f472:13f8 with SMTP id p33-20020a05687056a100b000e1f47213f8mr4331002oao.261.1649252213315; Wed, 06 Apr 2022 06:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252213; cv=none; d=google.com; s=arc-20160816; b=tO/gHM551Tzl7l+MIFt6fdtuJMZxmprbcXGiRUNxFdoabdyCyUKAYma1kbVtHIuHYg LAWer8DP1vYlUuoWBwLWs7L0X5YaDu01/8ScoWCgzVO16afTIo6hGE6VUINGDjlyfVyS lVQz/yJLfOTayGZ3hd2knKdndTGh/36OyElb/APU6x0eydOrtDNwe6rLrfq3sbwu9ZiC +Z8K8GMwzyzUA52NsIL/x12wcn7yJbEviUCd4uyDqewH8M5fWxMSx6I+e2RbX4ix+HtE IaziyQSKVRiXbaCyH1zVjIVJid5c5d86lWt+ZgR3sviZvZ+00aVBZj6npdwa5DDhXxBJ qobg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lR/AjW9NQybwoqwKLotrwUvTEPwdp1aLe2t9siML/w4=; b=JcBfilaOl62hEH8XbnCNDiRblUy8LnJ3PFsPs95NspFgdwMS9ZFIBtyS6VPin7fn1t /q5J+B219UcevivSgneqixr29Fr6FWXb2xMshVywlQdDtbZDyDN21qJlUCis6qPMEuyH cauLxLT661l77pejgxCrKVccrsgb4xgzcW/KwNscft/fyrtGCi55+zg6rjei0nuWWvXV P6MEvuiSoI/9WFC996aJGWemWfbLWccu0bhuDHMP5vbRNv6Eb6PNuMOb0mkae1zlOYXZ 0VAKi8pQb8XYWbW4d9rh/V+F9UNRoKzB4BfIfSIEnlz5S5WKIqCgU6vMfR2Zp3gibflI LoPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=id7mDuHa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 128-20020aca0786000000b002ef0c3475a4si9969686oih.36.2022.04.06.06.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:36:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=id7mDuHa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C99E45F2EA1; Wed, 6 Apr 2022 04:24:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442768AbiDEUHX (ORCPT + 99 others); Tue, 5 Apr 2022 16:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348751AbiDEJsb (ORCPT ); Tue, 5 Apr 2022 05:48:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E80F48321; Tue, 5 Apr 2022 02:34:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B04E5B81C6F; Tue, 5 Apr 2022 09:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFEA7C385A2; Tue, 5 Apr 2022 09:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151285; bh=vOzsy4dCO55H8J9nLmLlOgkfuzre8MNWIEBAqKkF684=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=id7mDuHaBPj3jy+kQz+6D4o4Rbp+MUzpB2JmbK1y3o58PKo9mVtaW6SvRRqs/Ph2u zELT82oQJl1EH/rbPXZ1Zsitvo6oRvKVcxD58CEVdHww9V6t8ZlkuFHBDYDzxs+D0J iR72GohdFAJnGh47COyWgTrvntTRgeq2XEl7lMx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Tzung-Bi Shih , Mark Brown , Sasha Levin Subject: [PATCH 5.15 359/913] ASoC: mediatek: mt8192-mt6359: Fix error handling in mt8192_mt6359_dev_probe Date: Tue, 5 Apr 2022 09:23:41 +0200 Message-Id: <20220405070350.606451968@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit e45ac7831ff3e2934d58cce319c17c8ec763c95c ] The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. This function only calls of_node_put() in the regular path. And it will cause refcount leak in error paths. Fix this by calling of_node_put() in error handling too. Fixes: 4e28491a7a19 ("ASoC: mediatek: mt8192-mt6359: fix device_node leak") Signed-off-by: Miaoqian Lin Reviewed-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20220308015224.23585-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index ab449d0e4e9b..c1d225b49851 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -1116,8 +1116,10 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) } card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); - if (!card) - return -EINVAL; + if (!card) { + ret = -EINVAL; + goto put_platform_node; + } card->dev = &pdev->dev; hdmi_codec = of_parse_phandle(pdev->dev.of_node, @@ -1159,20 +1161,24 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) } priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + if (!priv) { + ret = -ENOMEM; + goto put_hdmi_codec; + } snd_soc_card_set_drvdata(card, priv); ret = mt8192_afe_gpio_init(&pdev->dev); if (ret) { dev_err(&pdev->dev, "init gpio error %d\n", ret); - return ret; + goto put_hdmi_codec; } ret = devm_snd_soc_register_card(&pdev->dev, card); - of_node_put(platform_node); +put_hdmi_codec: of_node_put(hdmi_codec); +put_platform_node: + of_node_put(platform_node); return ret; } -- 2.34.1