Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp839789pxb; Wed, 6 Apr 2022 01:27:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYwe09GOHPLfL0kwy9Ft+D/GO7GIIT1TzLY0tD3mT7KzbgHsGlbJ0to4grvUmXL3Qew/Sl X-Received: by 2002:a17:902:b906:b0:14f:76a0:ad48 with SMTP id bf6-20020a170902b90600b0014f76a0ad48mr7569429plb.79.1649233657431; Wed, 06 Apr 2022 01:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649233657; cv=none; d=google.com; s=arc-20160816; b=igWU1uKyrAp6MQMoA4UQttG09vmwDAF5ee5FJY12TeiCyeDPzmC9k11/KP/4M4hN8/ UmtzkN8d9i481yC2uQRETr6gDOq+n/Tws7IpUk7BTLFzU95fLW7VZxY5rxiR3jqT2R3J Q04EibV8nOqNubUoVNN3DD2Q7EENeHHM3O0L8346xhV/GTX9j0nWfTQ5cHqyfMShQBIn gbtSfoUrDJYxVgo5qYs3DJAqfoddkEEriZNmYj0G1yz1kObNVRvW17H3cTIOcKUt3xLa HJvN4ZSSi1rM316q47d9RPzc63VjQVUx6qAjd5tKPW8dn0hUeQKmXUdeayPahujfqppX vDxg== 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=z64xT00G5W/8dOlazjYwKR3rB72RjkyMrfO2NR+YQzQ=; b=Ews1HQuMq3DvIlhCYdg/4OGpt4cFcGzXvSPOZNx/kKpRcZdhWWjc43VWW9aBBrX9jF YC6UJ03X4tpjTezRZ9iBfL+yDWUqojSrftmq51b3pNbl1ym7u/HbzcNYMqddKZepbSwe 3HZwRdtyFzdB2GcJVYfNuFymkii7zssLgrnr0tAdXpdOpelsapulxdjzi9+IV8tgrmTX i2ynBOUwzzGIq/CQYt1JZH+4yDmjwIx12cVQxGOb0I1rfON+g41UCBw68ogEWGSRxua0 gCWKAkcnf5hpbaUNtZHIJ7yLi0RGlOABsvk8a1aMRNhL9AXNxG/qbBeECOAMGXMEWrh+ 1Pxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hkct2b7X; 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 s14-20020a17090302ce00b00153b2d1646dsi14607928plk.117.2022.04.06.01.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:27:37 -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=Hkct2b7X; 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 52D08560DFE; Wed, 6 Apr 2022 01:14:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575758AbiDEXJC (ORCPT + 99 others); Tue, 5 Apr 2022 19:09:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348918AbiDEJsq (ORCPT ); Tue, 5 Apr 2022 05:48:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C46B89D0DB; Tue, 5 Apr 2022 02:37:26 -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 7889AB81B14; Tue, 5 Apr 2022 09:37:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4F75C385A2; Tue, 5 Apr 2022 09:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151444; bh=IvyBkfbeIWILmVXwush284Vcs9+1LeJ2nOw1//Ki3mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hkct2b7Xoe+xH0QFVYFDISsO9IzNJa+1dSLdDy112GFaRh2igLHhtAd938tZDYQED +qznEuckX7xJYcOQZjT4khf+GcILWLlJ0w7aYmJqDRFiHVrWbW9FPuTsDnw3A7+VXk BgwwwQAKhEbJADKyQvGHOm0+FE/sy1Ihch4+zS4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Codrin Ciubotariu , Mark Brown , Sasha Levin Subject: [PATCH 5.15 368/913] ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe Date: Tue, 5 Apr 2022 09:23:50 +0200 Message-Id: <20220405070350.877465536@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 740dc3e846537c3743da98bf106f376023fd085c ] 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 path. Fixes: fdbcb3cba54b ("ASoC: atmel: machine driver for at91sam9x5-wm8731 boards") Signed-off-by: Miaoqian Lin Reviewed-by: Codrin Ciubotariu Link: https://lore.kernel.org/r/20220316111530.4551-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/atmel/sam9x5_wm8731.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c index 7745250fd743..529604a06c53 100644 --- a/sound/soc/atmel/sam9x5_wm8731.c +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -142,7 +142,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) if (!cpu_np) { dev_err(&pdev->dev, "atmel,ssc-controller node missing\n"); ret = -EINVAL; - goto out; + goto out_put_codec_np; } dai->cpus->of_node = cpu_np; dai->platforms->of_node = cpu_np; @@ -153,12 +153,9 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to set SSC %d for audio: %d\n", ret, priv->ssc_id); - goto out; + goto out_put_cpu_np; } - of_node_put(codec_np); - of_node_put(cpu_np); - ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) { dev_err(&pdev->dev, "Platform device allocation failed\n"); @@ -167,10 +164,14 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "%s ok\n", __func__); - return ret; + goto out_put_cpu_np; out_put_audio: atmel_ssc_put_audio(priv->ssc_id); +out_put_cpu_np: + of_node_put(cpu_np); +out_put_codec_np: + of_node_put(codec_np); out: return ret; } -- 2.34.1