From nobody Thu Dec 18 08:37:34 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F28B7C38145 for ; Fri, 2 Sep 2022 13:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237618AbiIBNt6 (ORCPT ); Fri, 2 Sep 2022 09:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236960AbiIBNti (ORCPT ); Fri, 2 Sep 2022 09:49:38 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE66132ED1; Fri, 2 Sep 2022 06:24:26 -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 sin.source.kernel.org (Postfix) with ESMTPS id B8FAFCE2E6B; Fri, 2 Sep 2022 12:36:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F0E9C433D7; Fri, 2 Sep 2022 12:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122164; bh=coAGS/lQZ4tcWZ/q1MpitTrR7Gs3ITON93+C3oPxELQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rkjwAbHZnY+N4yP5OsHcb1XHsYBTdwP7WnF3gdruhk6ciOt8jEy4rgMJSSPzcO93i FSrtWkAQoi5xenWeGzVg5tOm8MFN+LG+3ChpiQ6+VSrnP9ajag0aMIpf6Ld8bqDZWw 39C9zZh4BorOW1fChQSTis9/iG6SGVVypSbS1prU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Biju Das , Mark Brown , Sasha Levin Subject: [PATCH 5.19 33/72] ASoC: sh: rz-ssi: Improve error handling in rz_ssi_probe() error path Date: Fri, 2 Sep 2022 14:19:09 +0200 Message-Id: <20220902121405.883050423@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Biju Das [ Upstream commit c75ed9f54ce8d349fee557f2b471a4d637ed2a6b ] We usually do cleanup in reverse order of init. Currently in case of error rz_ssi_release_dma_channels() done in the reverse order. This patch improves error handling in rz_ssi_probe() error path. While at it, use "goto cleanup" style to reduce code duplication. Reported-by: Pavel Machek Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20220728092612.38858-1-biju.das.jz@bp.renes= as.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sh/rz-ssi.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index e392de7a262ef..3d74acffec11f 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -1016,32 +1016,36 @@ static int rz_ssi_probe(struct platform_device *pde= v) =20 ssi->rstc =3D devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(ssi->rstc)) { - rz_ssi_release_dma_channels(ssi); - return PTR_ERR(ssi->rstc); + ret =3D PTR_ERR(ssi->rstc); + goto err_reset; } =20 reset_control_deassert(ssi->rstc); pm_runtime_enable(&pdev->dev); ret =3D pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { - rz_ssi_release_dma_channels(ssi); - pm_runtime_disable(ssi->dev); - reset_control_assert(ssi->rstc); - return dev_err_probe(ssi->dev, ret, "pm_runtime_resume_and_get failed\n"= ); + dev_err(&pdev->dev, "pm_runtime_resume_and_get failed\n"); + goto err_pm; } =20 ret =3D devm_snd_soc_register_component(&pdev->dev, &rz_ssi_soc_component, rz_ssi_soc_dai, ARRAY_SIZE(rz_ssi_soc_dai)); if (ret < 0) { - rz_ssi_release_dma_channels(ssi); - - pm_runtime_put(ssi->dev); - pm_runtime_disable(ssi->dev); - reset_control_assert(ssi->rstc); dev_err(&pdev->dev, "failed to register snd component\n"); + goto err_snd_soc; } =20 + return 0; + +err_snd_soc: + pm_runtime_put(ssi->dev); +err_pm: + pm_runtime_disable(ssi->dev); + reset_control_assert(ssi->rstc); +err_reset: + rz_ssi_release_dma_channels(ssi); + return ret; } =20 --=20 2.35.1