Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp898046pxb; Wed, 6 Apr 2022 03:38:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0uFOgbvttimelBRqqF9kE2S9Jym1lzbQk4v742t1Y40OkV1+xPCdJ0C/++dCfzggWVO6Y X-Received: by 2002:a17:902:b406:b0:14f:bb35:95ab with SMTP id x6-20020a170902b40600b0014fbb3595abmr7767524plr.140.1649241480890; Wed, 06 Apr 2022 03:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649241480; cv=none; d=google.com; s=arc-20160816; b=BKmAbf3KPOZJIkyxNTY7qN/jE5yRPbt4Mg/DsJiPfGRP4mxcT6FvjHkLTdWFlZL0x8 U+ue64r9J4UdBDNQs4/18/iFeqYrcOe4mU2TKSu1f8ENwsQ2UfbFeA9ppdXbr9wIM479 iYHDOOQXn0nek3FRG1LG9tg6I38zteDCNzpijakyEu0v6endxbkDP0uL5xTtXpwCRILk ti45ybT8oSXXWbkUpMZpaU6sBXCTB0po8xKLBsMNQKkMz09pyGcnmSVp6QuSNmydW3TC /XEFAsH7ZVPxrQTH9O+0pSVJV70yuJmjsn7S4cdOzBsuHdEccNmudvLCHE5fH6CDMCQU 9hnA== 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=j7R0guFvVuJvOyS60pY5/xJCJhUZLdQUy3sMFqDoMw4=; b=Y0w9v8b1L99dAWmv1Vk6BwnRTTQ7d/p8mKmHQjehvOsSU6b1/mGQZ5xMS6/eP9QFa5 qyZbMu1s7DV0jXsLqbNKuBYLm9/rM2gVleaLCO3oNv0+sRKKP2rbp1OEir6An8GcDKKu lXo5urKN3Mw92y0YXlzmAjp/KsFMr/FOicUAQGnfUYy2/d4Gu69oK9tKJv3wmY/HXPWx gpTdoKa51MPhaMLZ7LNZe92eTguG3QJi7zr4k7rCfi1cFmm58xnNKy9mHZ39pAi/eYar RdIJY7gJ2dxyXlmhvQCeNjoooRXxEW6wm7nVgJEejGX1TnlYzt8i1pyGsaHs3aCrJlI8 Ubug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k9z+qTzn; 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 c15-20020a170902848f00b00153b2d16647si9707226plo.591.2022.04.06.03.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 03:38:00 -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=k9z+qTzn; 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 EFA3B48BA92; Wed, 6 Apr 2022 01:59:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbiDEU4M (ORCPT + 99 others); Tue, 5 Apr 2022 16:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348730AbiDEJs3 (ORCPT ); Tue, 5 Apr 2022 05:48:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E40C3DDCC; Tue, 5 Apr 2022 02:34:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AD320616AE; Tue, 5 Apr 2022 09:34:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD09AC385A3; Tue, 5 Apr 2022 09:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151271; bh=pgnFe3HATdt1Pd0paifG5y7NhhasCQkzoDJ8+rs+IFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k9z+qTzn2I+Oi5XOJ8HYlZ7t7WKHu3aZw4XX981f1XUAzlsREMLPOEtTg1oKTHjmB 3BCMlxsYc9cQaYfX5WFm2G1okBQy8M76jlpj7HM0toN9JYMgXCjFRaqkKji8siQ0b8 RFsOniSl/58dMomP/wNYo8GFov/IhjWQt/g03jJE= 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 355/913] ASoC: atmel: Fix error handling in snd_proto_probe Date: Tue, 5 Apr 2022 09:23:37 +0200 Message-Id: <20220405070350.486585069@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 b0bfaf0544d08d093d6211d7ef8816fb0b5b6c75 ] 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: a45f8853a5f9 ("ASoC: Add driver for PROTO Audio CODEC (with a WM8731)") Signed-off-by: Miaoqian Lin Reviewed-by: Codrin Ciubotariu Link: https://lore.kernel.org/r/20220308013949.20323-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/atmel/mikroe-proto.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sound/soc/atmel/mikroe-proto.c b/sound/soc/atmel/mikroe-proto.c index 0be7b4221c14..93d114f5b9e6 100644 --- a/sound/soc/atmel/mikroe-proto.c +++ b/sound/soc/atmel/mikroe-proto.c @@ -115,7 +115,8 @@ static int snd_proto_probe(struct platform_device *pdev) cpu_np = of_parse_phandle(np, "i2s-controller", 0); if (!cpu_np) { dev_err(&pdev->dev, "i2s-controller missing\n"); - return -EINVAL; + ret = -EINVAL; + goto put_codec_node; } dai->cpus->of_node = cpu_np; dai->platforms->of_node = cpu_np; @@ -125,7 +126,8 @@ static int snd_proto_probe(struct platform_device *pdev) &bitclkmaster, &framemaster); if (bitclkmaster != framemaster) { dev_err(&pdev->dev, "Must be the same bitclock and frame master\n"); - return -EINVAL; + ret = -EINVAL; + goto put_cpu_node; } if (bitclkmaster) { if (codec_np == bitclkmaster) @@ -136,18 +138,20 @@ static int snd_proto_probe(struct platform_device *pdev) dai_fmt |= snd_soc_daifmt_parse_clock_provider_as_flag(np, NULL); } - of_node_put(bitclkmaster); - of_node_put(framemaster); - dai->dai_fmt = dai_fmt; - - of_node_put(codec_np); - of_node_put(cpu_np); + dai->dai_fmt = dai_fmt; ret = snd_soc_register_card(&snd_proto); if (ret && ret != -EPROBE_DEFER) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); + +put_cpu_node: + of_node_put(bitclkmaster); + of_node_put(framemaster); + of_node_put(cpu_np); +put_codec_node: + of_node_put(codec_np); return ret; } -- 2.34.1