From patchwork Mon Oct 24 11:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp467078wru; Mon, 24 Oct 2022 06:56:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+bd+r6Mg4w4BPiI5vZW/BJUNhZ0IXgxoEcdGw1eqypGe6hEfPVOjFQ02VwnCTXtPlv+AO X-Received: by 2002:a05:6a00:1389:b0:566:1549:c5bc with SMTP id t9-20020a056a00138900b005661549c5bcmr33993610pfg.8.1666619797953; Mon, 24 Oct 2022 06:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619797; cv=none; d=google.com; s=arc-20160816; b=CvQUlYJpy8yNdLw2U0BYDyWasI82hFu2k1MHClnyRZ62oeJlCe7pfx7T8O8QyqtpyB bKmCYO2THaYlZzlHruzS95iZcsweBJXEcTXOd3iMRBC4NPVUTsHzZbn3wQLFEQLpt0ok ucnKiBeCoBQ1Ao7FMimbSbL52VUx29dVE1pEnq3d2EPrpho3Wl4pEEwmya5ih+h/EABu xLIWIazAnQbCbHDoHD9YaigTTdRy1XZcS1CYDCjy4SD6Ur4MWg4oPzHYxsvvEPKND8rl F8dAO7ENU+TOXFHiFSjTHCwYdtfeXX9subCM3IGH6B5rH3E3kuCw5KM9dwy/J5leJH4D 0HZg== 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=7Ju4mMnvJDgb2H/c6C/eHk7yrFBYLq41nMph4eLUCy8=; b=QoShdPieH8pvFgM6YDS2ZXlq8hADpSewluBUeUTKAyDFqXBud1fjbjYhbdTzkK841W Cvn06qqRk/9cD7ElmLGOwHDPjFv5oev3xrSfBks0uwFT7J5XBvgLgWM8McVFp1aUbnBR 9b9FAVpyH3G4SKXYYIL1LwIP/hEl3M+iPfyyDx4uMzxbbf0D8lkUk1VhlwNdQiLfCffn UrKVEWaPQT/j50qDuVC8+44PocpI5dkDU2JfCGPZcgnKeymlE4XGvY9c/VYNYzR1H6Ye wfAJ5hICLlr11e5KB3kLmz1kD3IJt/QCe+jswmB6v9CNcbl1QiSC5lt7n+G8k4YSjLs3 bIAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="e26Mpln/"; 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 p10-20020a631e4a000000b004404162e5e0si36626149pgm.593.2022.10.24.06.56.25; Mon, 24 Oct 2022 06:56:37 -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="e26Mpln/"; 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 S236786AbiJXN4I (ORCPT + 99 others); Mon, 24 Oct 2022 09:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236767AbiJXNyD (ORCPT ); Mon, 24 Oct 2022 09:54:03 -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 9ADEEBC603; Mon, 24 Oct 2022 05:43:43 -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 8509F612FF; Mon, 24 Oct 2022 12:43:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B6ECC433C1; Mon, 24 Oct 2022 12:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615403; bh=0FgWjyKLI2um8JGHlqz65laz4O0Ndws/2JkNnZQ5x/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e26Mpln/PiNpVZ6IShUH/vn39lR74MJBpsdULGdBokqh0znIJ5wsWWIIEsmIMSxbQ ZViyaAPrlXpQKqbcPei3BlHILv0ivo49Ee0I/9y/oogfhMbl+lbZfQFm7bheN0BEyP s8W97SXjDFo2GKm72RV0cAqzJhn8zwKnfVEFspIg= 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.15 238/530] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Date: Mon, 24 Oct 2022 13:29:42 +0200 Message-Id: <20221024113055.874671211@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747577521164360399?= X-GMAIL-MSGID: =?utf-8?q?1747577521164360399?= 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 c7493549a9a5..da4c24b8dae5 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);