Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2027834rwe; Fri, 2 Sep 2022 07:32:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tc5Ij5UOu+rGRP9JXAfsweDGPAPkIDiRu926lFmwTajAkAX4GVtAuoG5bS56OOI0Nfx73 X-Received: by 2002:a17:902:a511:b0:172:97a7:6f5d with SMTP id s17-20020a170902a51100b0017297a76f5dmr35857649plq.159.1662129172143; Fri, 02 Sep 2022 07:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129172; cv=none; d=google.com; s=arc-20160816; b=1CMwEsDCzFabaVRKgQ11qdQplQeAbVj69KdctqDEIUb+nOpi7ZLEFuCa956r//23XD JE1dPFJgHy1fehM7Wbn4fbcD837OzZqNyE9CsIQ+RpLZfmk0zUXTzT4f6M+nck7Jv9kf 3jHcGxpA1guSx8sGFxXNx2aLpm//sq3rQ7B8mjyp0z6tTC4bU58kC2Iftn+moepFCKrb AhFW5aAER6aeOWW3Aztv7VdnQnQ8+eBsMSVV+PBVYb98soeB6wZnih1mbNw3tCwBPxcT nZS188236AbYG3K4hK5Mai0ih+62oZNFkQb8JYMnnZBdSHUxEJJmR6jcbnovxlK+Fvkb EGGQ== 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=N52m0xhaGrLiPjQaPPihU0YYhV6gcndnQA3MWH3gsvo=; b=RBLS4lac4StIOV0zkv1bDQONMWLmbDVgvKASCCdnEicitCpMLJi2H+WqtSW3Y7P1WG vnshu9rmolnyqVsF3vR0pf9C9Nft3PxMhuRoh6UcPRfnHLeN4Pmcmgt5ySO6Dje+iyFK ilatcO+BKIs80mmrl2mZAbwMUMtdhgBnRO/L/3Tmv7p2hBCdpLW7VmobRQR7Nzyq98pq dQufzaDuZf/LURw3+jSZk/eZbrpe3bdEDC1mrmcrbVNmApCsAZi2ls9ojJsBvOcKa2SD 1wm1w0Lz896YHIeGk9F+JlbBqKfBPphDAiGPVVQj5NpYH2xUHjwqeUEG2QTzeV5zaxWO +TmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rkjwAbHZ; 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 m14-20020a170902db0e00b00172cdd36023si2702025plx.51.2022.09.02.07.32.34; Fri, 02 Sep 2022 07:32:52 -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=rkjwAbHZ; 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 S238171AbiIBNt4 (ORCPT + 99 others); Fri, 2 Sep 2022 09:49:56 -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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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: 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.renesas.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 *pdev) ssi->rstc = 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 = PTR_ERR(ssi->rstc); + goto err_reset; } reset_control_deassert(ssi->rstc); pm_runtime_enable(&pdev->dev); ret = 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; } ret = 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; } + 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; } -- 2.35.1