From patchwork Sat Oct 22 07:23:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1097546wrr; Sat, 22 Oct 2022 01:08:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50Tg7OFb+d/I++tRlC9Ek7ed+/Sc1vBJbxXh6SPiQ7/Zdi/WkzXQKSnlfxl8qLCs8RdipQ X-Received: by 2002:a17:90b:38c3:b0:20d:406e:26d9 with SMTP id nn3-20020a17090b38c300b0020d406e26d9mr27120377pjb.121.1666426083521; Sat, 22 Oct 2022 01:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426083; cv=none; d=google.com; s=arc-20160816; b=q5XARww2b5sHCauDaxHLzEh9zGKEd7T+MkVMpyPwSfbdorGABZPS6dzUcIrAIE6115 h6YqchBWr2VLLs7N5TckTQASAGozy3YnXYa2NwnhW0gHQJaEBhc3Yzb1Y6bpP8q9VS06 FqbJp13P6CI0kgQMeDU2FMf+qHmVGxjPBy6wvIXS8hUdnQYuk2z+c5WiCBtaDDSoHmMk BY9CSLMzYSXo8v7hEkEiJEPMBX34ZVyWZZNvSgesk1xUpLgiwxgKRxk+YHd+EgOM5mhY S+fiSEBdjHviHpCUJLmjYlppZEGGbLF1skyJb7QntXIBgUgugZhzmFrK9lDHlN0skBLK ox6w== 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=9Ycj3RlJkZhC+LSxdpGzHKVaEHC2EedUHyf2k1jHE6I=; b=sGDDzn+uqgb4NRY53LOK5qXshLX4sf03b8ift9ozvZ5K51UTRzE2IlruhhOlC6ex0u VGR7JuDD4ejCoJAMHTTZObj/E4KHGSTQxk9FDrQXskL3JS2DxTp/4091OajsMwBZMgSQ ZAmFqVm8o+TZw2VzICqQuCHU1IbbtBiR3VNrh9DP3phDAJMDAzG3LgVSKFbFTkivZixt CxNDkoiL+nbfP8cMbbv70/YFwiNhRaihWpYDoPeQB827ADp33BRmLtJXJ2SXu+Fniy8w Dy0LGZdPr0Q+2dSCXZuGN1YUCfJ2A3zlK4uc1Mx8p8ZG65/RgE52ZJM5wwzosC/7M75S tkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iptKyllN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a170902bb8600b00176b8830921si23384784pls.294.2022.10.22.01.07.51; Sat, 22 Oct 2022 01:08:03 -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=iptKyllN; 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 S232950AbiJVIHg (ORCPT + 99 others); Sat, 22 Oct 2022 04:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbiJVIC0 (ORCPT ); Sat, 22 Oct 2022 04:02:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594F82A5202; Sat, 22 Oct 2022 00:51:09 -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 7ECC860B0A; Sat, 22 Oct 2022 07:49:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F693C433D6; Sat, 22 Oct 2022 07:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424949; bh=tFoKgWJaqjUw4lxxvnzsr2/zSpgY2MqNnWOONxKS3dU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iptKyllNOLL7glTLX0lYUaqZc79GgiKuJGxzT4Fa/pAU3plkCOauHscIi3rru4U6D ZPQ8jChzYLWWTHQkE0JKM51t4mZ2HjH/g0V7EgfFyZjndHdXSNd+zKGxEybMKPcSBm X0hkvv2cpg0FZ720qRLRcnjwIb99jcb601TBHHpo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Christophe JAILLET , Mark Brown , Sasha Levin Subject: [PATCH 5.19 337/717] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Date: Sat, 22 Oct 2022 09:23:36 +0200 Message-Id: <20221022072510.214461373@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374396947224014?= X-GMAIL-MSGID: =?utf-8?q?1747374396947224014?= From: Christophe JAILLET [ Upstream commit abb4e4349afe7eecdb0499582f1c777031e3a7c8 ] If clk_hw_register() fails, the corresponding clk should not be unregistered. To handle errors from loops, clean up partial iterations before doing the goto. So add a clk_hw_unregister(). Then use a while (--i >= 0) loop in the unwind section. Fixes: 78013a1cf297 ("ASoC: da7219: Fix clock handling around codec level probe") Reported-by: Dan Carpenter Signed-off-by: Christophe JAILLET Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/e4acceab57a0d9e477a8d5890a45c5309e553e7c.1663875789.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/da7219.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 7fdef38ed8cd..1bfba7ef51ce 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -2196,6 +2196,7 @@ static int da7219_register_dai_clks(struct snd_soc_component *component) dai_clk_lookup = clkdev_hw_create(dai_clk_hw, init.name, "%s", dev_name(dev)); if (!dai_clk_lookup) { + clk_hw_unregister(dai_clk_hw); ret = -ENOMEM; goto err; } else { @@ -2217,12 +2218,12 @@ static int da7219_register_dai_clks(struct snd_soc_component *component) return 0; err: - do { + while (--i >= 0) { if (da7219->dai_clks_lookup[i]) clkdev_drop(da7219->dai_clks_lookup[i]); clk_hw_unregister(&da7219->dai_clks_hw[i]); - } while (i-- > 0); + } if (np) kfree(da7219->clk_hw_data);