Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2958967rwj; Mon, 19 Dec 2022 10:58:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4yTrgeL5u1IlDZy2IK3DVSADCblEicLdUMeGjy4g8cS/2hH+SpNNNhUVu1SoozojqT2rie X-Received: by 2002:a05:6402:381a:b0:467:956b:1610 with SMTP id es26-20020a056402381a00b00467956b1610mr36541575edb.0.1671476330750; Mon, 19 Dec 2022 10:58:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476330; cv=none; d=google.com; s=arc-20160816; b=jGA8UqYcseh6DRk3iufqJ9tLnO/lhaz2cN212f0IDf2AmZ4ERHZLt/R7R/96hJ1TZE SXPcN4jJlx0f5I1kWQ5pPE8NOpb/JyWRrWpiSCs94rD9CzQ4qogVI4YK8KuFGlY6rKf6 iGHq1IeHi/NNElY326palTAmjhXSqb/tGokuL0p+x/WWypTLMxLEFlLxuGqFVm4vp8Uj LDr9Ei1AHM5kJPYKR1n6maTWweNKcYBhNj271iHNTce9QetTlAgUATgfnI0JhAy2Rfrf vB+WqBHeq9pwc9i52U3u1Tlvz48zR/b8uko0X+uXLCRZO2yE9qO5ipabI9cTezeO5nMq 2eeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rhpuRs15Dkd7RSjm8roBGpRn5wYfY2Q6OrR3reT4HY4=; b=Z/sRRYTZ3q8J1oHez0ULzh+oenwu6OCguCDJmHemKU4eIW4bEmoFap+hvmdPzG8/7T B8T2q+nQn17KdtA4KVh+/pAxAJMD0R8+gksxCdubEPdyyOY6x+46J4jUDB69HeKmviP2 ZWJDzNKYJEeZ8Z1G/0+fnzYoGv2W5hJ3y4970W+AAZghXVBygYvSEWsEgxTsLlVmOozB Ku5MIonBZ50eDnXpJyL/qp3xU9bO9iL8fj83+ELXA9wu3zeedVpgj2S/IZKfCn3f7c1u NAHEWaD7hhESfZWTmgvXVwijl9UAAa9xvkeg9CZoT+hoVGxIkaoMDA43SGg5yqwt2XWV hRsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q1s5akx7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a056402430d00b0046b32882b04si10702412edc.440.2022.12.19.10.58.34; Mon, 19 Dec 2022 10:58:50 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=Q1s5akx7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbiLSSRL (ORCPT + 70 others); Mon, 19 Dec 2022 13:17:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbiLSSRD (ORCPT ); Mon, 19 Dec 2022 13:17:03 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD53E26DE; Mon, 19 Dec 2022 10:17:02 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id ay40so7062072wmb.2; Mon, 19 Dec 2022 10:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rhpuRs15Dkd7RSjm8roBGpRn5wYfY2Q6OrR3reT4HY4=; b=Q1s5akx7wwCpP5YF8xryCFNBrkOCDE2qI/EAA+0JkX09BgsP/K4m1uoT1xiGq4HpBG SGJrjdT7drzhdDLYX59ZYT8qdAdcoUf3M3xhmXq3rtAKExt6NGKq7E4WWTz5QdgxbIOI rOlin1X6fQ9/e5J7XD2JARPzhT1hxnHfa04/1zHeULrZ3C10M8KHlJAUsxRWUSstkWKN YljHIAdNa+xNLetOeuCq/z5pCcnEL4l5bC3WagQ2ZEwDySqrqMR0yv/EFyKdy7VKCQeU dVbTa4plFSqKtfiMQslYxgshY/Z3fZyLHAGhZtXxeU5wDj5ApwdIEZ/j1+UXF5Vr91OW V1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rhpuRs15Dkd7RSjm8roBGpRn5wYfY2Q6OrR3reT4HY4=; b=1EGHqkjPYZkAx9FxC4vEKjM9ZX/TheA12VOGSujsmMn0AEiem7BdbNITkdQJfGhbyX 8nBrtX/X8paYvPZLRsf2t9ls+BONHm9ZvMyufRNExLGOPEWSTLrbyxkTnXJ/ZXJUSlCL +N+y31PrlfcTJPGSInIZRL9nGbTxy2G4sdPxuY8Y/x1zSii/STMq6waI6yxLcHfUFiLQ /GQZE0ojEF3Sobi7lPgqWDDRGjoqRgYaDBM0IR2Yaj1mfyHnMK0tD9gsI3HNQoI/EezW CXvOvMUNouEq6WASHmgiy+jjXiZdsRgxc29v++iuZsrgfQimpkI3ryxX93bBHRdfoJgE 871Q== X-Gm-Message-State: AFqh2koq2EcjB/6V5YcElTjiotAEbiHQ5pdmBOz0aGxb9CjldO6oFbsi 4333KaKkT5Cds8ijFB63Xuo= X-Received: by 2002:a05:600c:35d3:b0:3d3:5ccc:4442 with SMTP id r19-20020a05600c35d300b003d35ccc4442mr1636409wmq.26.1671473821394; Mon, 19 Dec 2022 10:17:01 -0800 (PST) Received: from [192.168.2.177] ([207.188.167.132]) by smtp.gmail.com with ESMTPSA id y21-20020a1c4b15000000b003d1b4d957aasm13120406wma.36.2022.12.19.10.17.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Dec 2022 10:17:00 -0800 (PST) Message-ID: Date: Mon, 19 Dec 2022 19:16:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe() Content-Language: en-US To: Christophe JAILLET , Yong Wu , Joerg Roedel , Will Deacon , Robin Murphy , Honghui Zhang Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Joerg Roedel , iommu@lists.linux.dev, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org References: <593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr> From: Matthias Brugger In-Reply-To: <593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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 On 19/12/2022 19:06, Christophe JAILLET wrote: > A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in > the error handling path of mtk_iommu_v1_probe(). > > Add the corresponding clk_disable_unprepare(), as already done in the > remove function. > > Fixes: b17336c55d89 ("iommu/mediatek: add support for mtk iommu generation one HW") > Signed-off-by: Christophe JAILLET Reviewed-by: Matthias Brugger > --- > Another option would be to use devm_clk_get_enabled(). This would save a > few LoC in mtk_iommu_v1_hw_init() and in the remove function. > However, it would change the order of function calls in the remove function > so I leave it as-is. > Let me know if it is fine and if you prefer this alternative. > --- > drivers/iommu/mtk_iommu_v1.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index 69682ee068d2..ca581ff1c769 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -683,7 +683,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) > ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, > dev_name(&pdev->dev)); > if (ret) > - return ret; > + goto out_clk_unprepare; > > ret = iommu_device_register(&data->iommu, &mtk_iommu_v1_ops, dev); > if (ret) > @@ -698,6 +698,8 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) > iommu_device_unregister(&data->iommu); > out_sysfs_remove: > iommu_device_sysfs_remove(&data->iommu); > +out_clk_unprepare: > + clk_disable_unprepare(data->bclk); > return ret; > } >