Message ID | 20221018024258.19073-3-yong.wu@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1746575wrs; Mon, 17 Oct 2022 19:51:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XyMxaAPpPY9KvB8GC/8+H1Gmz8QjRNGcR+Ppwy66wBAIHnBsOPW4Ju41c+Y4nTrgaQMAl X-Received: by 2002:a17:907:e93:b0:78d:46b3:3a76 with SMTP id ho19-20020a1709070e9300b0078d46b33a76mr592039ejc.133.1666061484417; Mon, 17 Oct 2022 19:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666061484; cv=none; d=google.com; s=arc-20160816; b=DLyP+Q9+PcAfR516fJ9j4nFNP7hCBWf031T1PHEi7zQ/MgDsT+a3//7rEy3N6JxdFs 322U9Y8bLl0RIFZ7XMYSMYQkpiIlwLYkETagkk61gh6fDb307R2hyP1XlshuFAdrCP06 YH/8c5RRwQtqXBbew4LJd6dzLX5uAbLQcMErxZiv+ho0d606eBlvt4F4U4hQUfy/J5Yp 5OzQBuKsHsMVqvj2q01gzQs2lE9LmuSv9bjtxDLQe4Pe5yRv+xjaQsy2HNqhq2ucaI0K dK7IJIlIKp05C3mK99BeqtV4y6Dv3TaL6xwvRLCHuXZGeUnpd/VH6gjVG1ciwEpmbjXi WRJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GfOnCmQ4os1l9pK8r60xypilBfa/Y0HGBb2etrLS7hA=; b=ratsRth7ZYn13+o0LeQeQFw3dGNXIdsoqDDrpSLuTpGhw7yxS7VBCsZlZIQDvhsvw0 LYCIpsvXAQXqJtqV49SsO2y8HpR55D+DKMs0pjZOPvB3tGkbqeAauxqzRK7qGZur4j6W MvedVZOV7wNfi/gLwiN2hdEbuGaETZkwJWV6pRnXqNg7W7Rufi7mDxf1yzFLeMon8R04 vWYqhCn0qIGDczlRXj4ZV/uag3yY+/DExI5fc8iRSpBD5NE/+j2AoUG+Lq36UlA62eAX wnRwp6leUdP5gAtR/NeS8jiKIyayzYqgGdLcEnzoa6EsPvU8iMZxprMQQ/UmP021/aCx wBXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=tln09LX4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020aa7c386000000b00457cc36dfe3si9184662edq.159.2022.10.17.19.50.59; Mon, 17 Oct 2022 19:51:24 -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=@mediatek.com header.s=dk header.b=tln09LX4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbiJRCnp (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Mon, 17 Oct 2022 22:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiJRCnh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Oct 2022 22:43:37 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FAB996234 for <linux-kernel@vger.kernel.org>; Mon, 17 Oct 2022 19:43:33 -0700 (PDT) X-UUID: 1fd959f09913444192db8ec4ae3c4351-20221018 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=GfOnCmQ4os1l9pK8r60xypilBfa/Y0HGBb2etrLS7hA=; b=tln09LX4T+lHBcWoV9vx5tA8/cClwSd7Xz7RpReSW+gGdj68OqPPJaeYWk5igoIxw50G9mL1tvxez6sc2o0Q0RYM0YBkPxwdu/zaCagCOn3zJ1GnzRBHpcwjnraZbm87q2+8RZZXeNTjS8WWjiCFeg6n7PNaEqanvyZYChDKT2c=; X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:b246a133-117a-4f68-b49f-60d4637a0e23,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:75 X-CID-INFO: VERSION:1.1.11,REQID:b246a133-117a-4f68-b49f-60d4637a0e23,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:75 X-CID-META: VersionHash:39a5ff1,CLOUDID:62cd17a3-73e4-48dd-a911-57b5d5484f14,B ulkID:221018104331G9A3AB6L,BulkQuantity:0,Recheck:0,SF:38|28|16|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 1fd959f09913444192db8ec4ae3c4351-20221018 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from <yong.wu@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1558263475; Tue, 18 Oct 2022 10:43:29 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Tue, 18 Oct 2022 10:43:28 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 18 Oct 2022 10:43:27 +0800 From: Yong Wu <yong.wu@mediatek.com> To: Joerg Roedel <joro@8bytes.org>, Matthias Brugger <matthias.bgg@gmail.com>, Will Deacon <will@kernel.org> CC: Robin Murphy <robin.murphy@arm.com>, <iommu@lists.linux.dev>, <linux-mediatek@lists.infradead.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, Yong Wu <yong.wu@mediatek.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, <mingyuan.ma@mediatek.com>, <yf.wang@mediatek.com>, <libo.kang@mediatek.com>, <chengci.xu@mediatek.com>, <youlin.pei@mediatek.com>, <anan.sun@mediatek.com>, <xueqi.zhang@mediatek.com>, Guenter Roeck <groeck@chromium.org>, Dan Carpenter <dan.carpenter@oracle.com> Subject: [PATCH v7 2/6] iommu/mediatek: Use component_match_add Date: Tue, 18 Oct 2022 10:42:54 +0800 Message-ID: <20221018024258.19073-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221018024258.19073-1-yong.wu@mediatek.com> References: <20221018024258.19073-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746992086963296636?= X-GMAIL-MSGID: =?utf-8?q?1746992086963296636?= |
Series |
iommu/mediatek: Improve safety from invalid dts input
|
|
Commit Message
Yong Wu
Oct. 18, 2022, 2:42 a.m. UTC
In order to simplify the error patch(avoid call of_node_put), Use component_match_add instead component_match_add_release since we are only interested in the "device" here. Then we could always call of_node_put in normal path. Strictly this is not a fixes patch, but it is a prepare for adding the error path, thus I add a Fixes tag too. Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM TYPE") Suggested-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/iommu/mtk_iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Comments
On 18/10/2022 04:42, Yong Wu wrote: > In order to simplify the error patch(avoid call of_node_put), Use > component_match_add instead component_match_add_release since we are only > interested in the "device" here. Then we could always call of_node_put in > normal path. > > Strictly this is not a fixes patch, but it is a prepare for adding the > error path, thus I add a Fixes tag too. > > Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM TYPE") > Suggested-by: Robin Murphy <robin.murphy@arm.com> > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> > --- > drivers/iommu/mtk_iommu.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 3189b585725f..38112ad87d70 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -1068,19 +1068,17 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m > id = i; > > plarbdev = of_find_device_by_node(larbnode); > - if (!plarbdev) { > - of_node_put(larbnode); > + of_node_put(larbnode); > + if (!plarbdev) > return -ENODEV; > - } > + > if (!plarbdev->dev.driver) { > - of_node_put(larbnode); > platform_device_put(plarbdev); > return -EPROBE_DEFER; > } > data->larb_imu[id].dev = &plarbdev->dev; > > - component_match_add_release(dev, match, component_release_of, > - component_compare_of, larbnode); > + component_match_add(dev, match, component_compare_dev, &plarbdev->dev); > platform_device_put(plarbdev); > } >
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 3189b585725f..38112ad87d70 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1068,19 +1068,17 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m id = i; plarbdev = of_find_device_by_node(larbnode); - if (!plarbdev) { - of_node_put(larbnode); + of_node_put(larbnode); + if (!plarbdev) return -ENODEV; - } + if (!plarbdev->dev.driver) { - of_node_put(larbnode); platform_device_put(plarbdev); return -EPROBE_DEFER; } data->larb_imu[id].dev = &plarbdev->dev; - component_match_add_release(dev, match, component_release_of, - component_compare_of, larbnode); + component_match_add(dev, match, component_compare_dev, &plarbdev->dev); platform_device_put(plarbdev); }