Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp821827rwi; Wed, 19 Oct 2022 03:29:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ABnI0y3QPrxQ3odzKAtVH9ekJowLCUVzZTyIIZnjfA2yKKV8Dz2CUOa++7HE07MmcaJBr X-Received: by 2002:a05:6402:50cf:b0:45c:dfce:66ae with SMTP id h15-20020a05640250cf00b0045cdfce66aemr6474138edb.370.1666175343034; Wed, 19 Oct 2022 03:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175343; cv=none; d=google.com; s=arc-20160816; b=Bo6QhFzfj+1oEp55JB2+4s4S+6VVIzNnUzP2Z/lHGHeWmCo32N2xF34y/bB080co6n ihx/Knj8KXE7tW8SUvg7QArnkF9YEojmaSOEuccx1HdIFIJP0J8Um4bDVPif/vb5ZHoG N3LvDwuGJ0LtjmLHQCfjIk0Tm/jKQH3ma0S8ygdispV/blgyjexJKjBuL3ztHeqI7ZID sG5lbvLTL3T32mXXIE8LEeZRA+hSjPSdRoIg0WtTXd/7noTN/tqsNOL8CyDAQGZDJvTi ZpbRm7lA5kpmqgtu+P54wNQnUKjkYVx/GVARGjAPURKnUVaOJMblqAT8XXEBTbq4COt0 vhcw== 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=YK+T+Rs4gq61ULEwA1OLY48M2PfAG9R7yj1D1IAm108=; b=xUXMPr+9C/y2Sf06fdTe8yd1/YjAJxcSDoE6AbscTpW2w7fSFAoiQt5dd8f9Es9ScL kzYrm6RnPMEu8XcSLSdCyvAMOho0SU3mvy/y7vDK2PNMPRMbqoXVJzoBaChH6q4qYV0D Tn9IlY8DQf+gLQptI0V5mHBqW6TZibPf3eRtBAKG4gUIwzrpwN6Xy9hEDst0ngR+vLTz jCdCqOyZQuyAbk4FMPuvzTfEifCpuQDLeDJG5SmZDsOeNVXRbQRl03Zf6D6GAMBJ1xTY oDOlcYslgcSGGWD1pG0P2jZvacQNBWGJOhp5v0Vwe/iEQwlu/yn5H/VQQM6zzkbG7PfV 7cqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xA2M8yJf; 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 dn16-20020a17090794d000b00730870cb4b6si10942221ejc.621.2022.10.19.03.28.36; Wed, 19 Oct 2022 03:29: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=xA2M8yJf; 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 S232369AbiJSJGL (ORCPT + 99 others); Wed, 19 Oct 2022 05:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232504AbiJSJE0 (ORCPT ); Wed, 19 Oct 2022 05:04: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 A6251AC3B0; Wed, 19 Oct 2022 01:57:40 -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 43AE5617D1; Wed, 19 Oct 2022 08:56:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F65CC433D6; Wed, 19 Oct 2022 08:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169771; bh=4VSYuPSAObcReK/9L0QMwHxCF101x1ZYOeGQCscVZRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xA2M8yJfsxEoruSqLaTlbOoIKhz62Lqk3e6YAvnghseeGA4a/W93OBLJL3KwgIAjd 6/aUUuIU5KiO7jEp3WaF28Hf9ryNl9nzEMaB+4nWABl6ePGBqOv1hI9wHubKcIEODW TGyqmv1YPrAGS1GFBe7c2qfy9FbHv010bJkMPdlg= 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 6.0 402/862] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Date: Wed, 19 Oct 2022 10:28:09 +0200 Message-Id: <20221019083307.703059785@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 50ecf30e6136..4746c8700451 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); -- 2.35.1