Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3440147rwe; Sun, 16 Apr 2023 20:29:12 -0700 (PDT) X-Google-Smtp-Source: AKy350YJf7Ag95B1F7KgL8ENb8Vfnh9HGX1lfs6CUL78XkI+qqpjQf9QDm50hh1YvmDVlYAKvoaV X-Received: by 2002:a05:6a20:4282:b0:f0:f2a:ff4f with SMTP id o2-20020a056a20428200b000f00f2aff4fmr860199pzj.8.1681702151893; Sun, 16 Apr 2023 20:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681702151; cv=none; d=google.com; s=arc-20160816; b=IDI4IN7fUULa6yafw3zXw2ZQuMLEjPtInql8RrrpXYTc/N7t2aZMKqOYUIwgbk/CQQ craBEND4tsi97dkPGKT+DHN2urzd7nFNr2PQ9sWIksqhXB+7P/QQaXtcj8VQ0KcyF87e may3qypUggO6FrFnAea+5ANl75g/c/uCQtrUVfR5X3reiuCPBi3ejrVNa1xDfDrYtk8C rjofQLAHcqyza6m04wx4RrdIooEZZXxSVKnHH5uYRV/xuA4AJgUMIiBv6tau8jdT5RVR fPjQBlIXhcxC58730Mx3x8h4c1YbSowZrFDFNKhM6E4D4aJk5oShDyLrFzL0v21MgY79 ujMg== 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 :message-id:date:subject:cc:to:from; bh=PbDkgK7kjteruxQfyZ01ky2PDARHHPRcp9tlsZk2IiA=; b=f6xSrNLA/xEjO/ZmwT6q1XnGQ89w6rdveIi/7fM4Oo5dnfW1ysdazEIdLSTZAG3b30 f/rvHtCl+GaJAYt8j9KEbr9g46v1+pbx+VXNSXkiGpVfwTodR8CdTS5+kVDp8UU6pUCc ESU+6GfrV3Ahhv3uGoN+BhcqRnI86+MkXeY57uol8kBF/q1rCKxk58tQpuzT1m8LTAR1 E4vrp2ZiHDnOEDZnljfWL4Y+uNCYmGWM7KuFbLEa4yO21yGLecDvxLTLdWyPeZNGVqCm hb0fUAcJzQSkD7Fq5xI93wPKogAsmgOCRcAaOJCd9rDItNdAKQLM3StThMowc50LpbIK tZxw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n32-20020a635c60000000b00502fdce9dcasi10698609pgm.114.2023.04.16.20.28.59; Sun, 16 Apr 2023 20:29:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjDQDTG (ORCPT + 99 others); Sun, 16 Apr 2023 23:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjDQDTE (ORCPT ); Sun, 16 Apr 2023 23:19:04 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E60B1FC4 for ; Sun, 16 Apr 2023 20:19:02 -0700 (PDT) Received: from wangchao.. ([10.12.190.56]) (user=D202280639@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33H368pS014728-33H368pT014728 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 17 Apr 2023 11:06:11 +0800 From: Chao Wang To: Joerg Roedel , Will Deacon , Robin Murphy , Heiko Stuebner , Marc Zyngier , Olof Johansson Cc: hust-os-kernel-patches@googlegroups.com, Chao Wang , Dongliang Mu , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu: Fix unwind goto issue Date: Mon, 17 Apr 2023 03:04:21 +0000 Message-Id: <20230417030421.2777-1-D202280639@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: D202280639@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Smatch complains that drivers/iommu/rockchip-iommu.c:1306 rk_iommu_probe() warn: missing unwind goto? The rk_iommu_probe function, after obtaining the irq value through platform_get_irq, directly returns an error if the returned value is negative, without releasing any resources. Fix this by adding a new error handling label "err_pm_disable" and use a goto statement to redirect to the error handling process. In order to preserve the original semantics, set err to the value of irq. Fixes: 1aa55ca9b14a ("iommu/rockchip: Move irq request past pm_runtime_enable") Signed-off-by: Chao Wang Reviewed-by: Dongliang Mu --- This issue is found by static analysis and remains untested. --- drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index f30db22ea5d7..31cd1e2929e9 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1302,20 +1302,22 @@ static int rk_iommu_probe(struct platform_device *pdev) for (i = 0; i < iommu->num_irq; i++) { int irq = platform_get_irq(pdev, i); - if (irq < 0) - return irq; + if (irq < 0) { + err = irq; + goto err_pm_disable; + } err = devm_request_irq(iommu->dev, irq, rk_iommu_irq, IRQF_SHARED, dev_name(dev), iommu); - if (err) { - pm_runtime_disable(dev); - goto err_remove_sysfs; - } + if (err) + goto err_pm_disable; } dma_set_mask_and_coherent(dev, rk_ops->dma_bit_mask); return 0; +err_pm_disable: + pm_runtime_disable(dev); err_remove_sysfs: iommu_device_sysfs_remove(&iommu->iommu); err_put_group: -- 2.34.1