From patchwork Mon Oct 24 11:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp453868wru; Mon, 24 Oct 2022 06:28:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Lp8DGjAIswpsxypIhW80hp9aekJMCORfhb+mjaFYzCbvVcDcH7yp2kiDdCNMp2do50n4u X-Received: by 2002:aa7:d30a:0:b0:460:362e:af11 with SMTP id p10-20020aa7d30a000000b00460362eaf11mr22132989edq.256.1666618134496; Mon, 24 Oct 2022 06:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618134; cv=none; d=google.com; s=arc-20160816; b=0aeWhbS/mkhqeysExgTMHIoMI310uAsPMevpcwunNyK0iph8QbcdfnND+duUYoldiC 73xO+YTArqgMsj0YYPtY4bJmmHaYbLm2uHQVSyeaCax7oK3VtXZkzws1hmkrLHjWtyC1 UHtGuDyBxsuOUFAM/8BLr8JsjcfrtmdQrqk+YJTu0z1s/I6ZEQkqxuqXoVKz5fEjrGFE pjuI9kKqm1wYVyeb5TiyLSG+vDW+q4Hrg0Pz8pZru7e+ADgidWrXBQnfSnJZabGKKtbp tGOp1YpAlAhHKpHxv8Hhpkc5AJU9ZZz/P4SUKSPmP+4QnNOCqGkElbxpGsNOOVSbcGgx L03A== 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=MToBfOeK0tWDwedqcFVk3wR7Th8ndGbW6UGN7+0cuz8=; b=z0ob3q+aI38v/OpUpyUR50tf9HbcmPMGOJTFvzXV25+ywj0REwVs4mnYqZ7vlbNrTb 19qzjKbyN+ouqONBjS4hcpjCnSGe/qWYhRwU7MDom6qauFETLsRQPopGa9uphngoS+S+ ka0rgiFH/+wBaKCqAaRVIDQY2LqHxYHFx1RbICC3FcJwVKIQuhjH/6pcGwayZlq9t0P7 NXFKzTQtgojay1lfYT+e/mRoyctZ93thignNEarMPimM7ZoeSR2m5OReLgwU6Lil2hcM jzQOmas4VF3TgR8l6olKIZkI15d3ERkG3RSllYuNtBMnUVqZ3HKWlpsFhM/ZUQPkHeZL 9cHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YJUY4djY; 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 ec33-20020a0564020d6100b004615a57e292si7715742edb.426.2022.10.24.06.28.29; Mon, 24 Oct 2022 06:28:54 -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=YJUY4djY; 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 S235802AbiJXNNP (ORCPT + 99 others); Mon, 24 Oct 2022 09:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236041AbiJXNKb (ORCPT ); Mon, 24 Oct 2022 09:10:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0AD4275DB; Mon, 24 Oct 2022 05:24:13 -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 0692D61218; Mon, 24 Oct 2022 12:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19686C433C1; Mon, 24 Oct 2022 12:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614179; bh=biVTL9eoN7LxL7wN3GMR5ldMXPiMF4nfAD7JmXl/RMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJUY4djYtOohT9bj3plWQ/YEu9qsfTfkag0Mkjj3lIQexYX1ANe68I9cWF+NZYn+b zSZm0V+IWT3p3MPX+6A8oFMbFV4iBB45sjwxDEuhThVyqVREcJzsLjq5kuGkRDYcyd 8DDh6XPjW3cDm4561pH7GUO0ID5Ut0LEEF/MERH0= 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.10 163/390] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Date: Mon, 24 Oct 2022 13:29:20 +0200 Message-Id: <20221024113029.651050987@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747575776748859448?= X-GMAIL-MSGID: =?utf-8?q?1747575776748859448?= 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 5f8c96dea094..f9e58d6509a8 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -2194,6 +2194,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 { @@ -2215,12 +2216,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);