Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp690449pxb; Tue, 5 Apr 2022 18:56:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz86RTS+ZlXLVjm1pKy9kYCAxiwcekcKyQ9gAbIOmcok5WxHNa3hSyxGHIq9KiVLsw2lh8i X-Received: by 2002:a63:f648:0:b0:380:a9f7:2189 with SMTP id u8-20020a63f648000000b00380a9f72189mr5191877pgj.305.1649210188236; Tue, 05 Apr 2022 18:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210188; cv=none; d=google.com; s=arc-20160816; b=SdZP+ZxEyEemBweBf7x5BiEb+2Ph0DOfR3b1Gxc8mllg7bEtDfkOWVvR7AVYNo7OcN W4XxDZX5SWWLkcx4aOFsshzHYT3ZpcUGw1iXuMw/hLZWsMCcdUTJtVHkEBcMyxgkoOjB VRlbb4k32YJNxTskngde9D2oLE6LAD8+b3E5wj/5+yt4F1Wxn5iJNOGF9ykURzARcfl/ O2jYC7Do7Khwco3+P7N39YKu7MksbT1kPSf1VnvhNknV6yWCjqrZA+qiUqcxpSr/xGYG BYE830UCHe67H9tc+UMiv+Btj0rkHuxBOcMQz87jEff8sZiOhqvlb/6H2t9+Ig6jRqpk SClA== 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=xGOmD9FrBC6oc+18ob7K8Amy1fV2nTzQiAzIQ9P3WTc=; b=LXeu+LiWyDkdH6YoJL7JE316w2CS2aApWRDn3l+sK7GQ35rVpin3Unc8otXzRg9dg0 6RBLclMGzMxUOwnPaeE/zPyvy13lOSjtr+ELpgj2uDXFyfBX1pkh8esSVv642ciiHgvq 0mLAtilMEQsxanUbBzVR3vL87DfTJsp0goJJpwZyVmn3EJ5lS+00b4y0mJSDiMCQalJ1 IUPRZ/4xSEnV/gBP2B5KaufFhfymzUKEYv6YQGF0RW/qiZR7812O6C3rxnCUpChz1h6K vycX2gh+yYlZQ0fRgr1r7ARf7+80wNIEm3c8cnYbvbj4upKKFHgUJDOwETAw4k5HgZIb YnAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dIbcUki8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020aa78001000000b004fa852292b0si12646184pfi.308.2022.04.05.18.56.14; Tue, 05 Apr 2022 18:56:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dIbcUki8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238037AbiDEISh (ORCPT + 99 others); Tue, 5 Apr 2022 04:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235660AbiDEH77 (ORCPT ); Tue, 5 Apr 2022 03:59:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 617F0165AD; Tue, 5 Apr 2022 00:57:08 -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 F198F6167D; Tue, 5 Apr 2022 07:57:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E4BEC3410F; Tue, 5 Apr 2022 07:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145427; bh=PGNhh9vDo9jGvnljvgoqHxuHIDx8W3OpabSkNU6DKU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIbcUki8Nn1RnBk58FZShV5aVYOkEmiJ2AuDZ+TuA3vTd8yU1EXCqfPkMIlELZD1y GsMUcmaPGVXbgmgoeatI2cXzwii3W+i+bC8Xf7iMSYztpD00OhFMbVupJAOkNla7cI Pywi3mkbWC2To01cPtBIwzumFGe/aEtVHhgrl0rI= 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.17 0401/1126] ASoC: atmel: Fix error handling in snd_proto_probe Date: Tue, 5 Apr 2022 09:19:08 +0200 Message-Id: <20220405070419.397025798@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 627564c18c27..ce46d8a0b7e4 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) dev_err_probe(&pdev->dev, ret, "snd_soc_register_card() failed\n"); + +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