Skip to contentSkip to conversation

iommu: fix parameter check in tegra_smmu_debugfs_init()

PATCH Superseded Minjie Du 3 participants 5 messages Jul 12, 2023

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Minjie Du

author
#0 lore raw

PATCH 1/1 iommu: fix parameter check in tegra_smmu_debugfs_init()

Make IS_ERR() judge the debugfs_create_dir() function return in tegra_smmu_debugfs_init()

---
 drivers/iommu/tegra-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/tegra-smmu.c +1 -1
index 1cbf063cc..841e14cce 100644
@@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
 static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
 {
 	smmu->debugfs = debugfs_create_dir("smmu", NULL);
-	if (!smmu->debugfs)
+	if (IS_ERR(smmu->debugfs))
 		return;
 
 	debugfs_create_file("swgroups", S_IRUGO, smmu->debugfs, smmu,
Signature · 1 line
2.39.0
#1 lore raw
Quoted 13 lines · Minjie Du

Make IS_ERR() judge the debugfs_create_dir() function return in tegra_smmu_debugfs_init()

---
 drivers/iommu/tegra-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/tegra-smmu.c +0 -0
index 1cbf063cc..841e14cce 100644

drivers/iommu/tegra-smmu.c DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients); · line 1060

Quoted 6 lines
drivers/iommu/tegra-smmu.c +1 -1
@@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
 static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
 {
 	smmu->debugfs = debugfs_create_dir("smmu", NULL);
-	if (!smmu->debugfs)
+	if (IS_ERR(smmu->debugfs))
 		return;

I think we can just drop the error check altogether since debugfs_create_file() will simply return early if smmu->debugfs is an error pointer.

Thierry

author
#2 lore raw

Hi Thierry!

Quoted 2 lines

I think we can just drop the error check altogether since debugfs_create_file() will simply return early if smmu->debugfs is an error pointer.

So do you mean maybe delete the smmu->debugfs check is better? Maybe I can resubmit a new patch.

Regards,
minjie

-----邮件原件-----
发件人: Thierry Reding <[email protected]>
发送时间: 2023年7月12日 20:22
收件人: 杜敏杰 <[email protected]>
抄送: Krishna Reddy <[email protected]>; Joerg Roedel <[email protected]>; Will Deacon <[email protected]>; Robin Murphy <[email protected]>; Jonathan Hunter <[email protected]>; open list:TEGRA IOMMU DRIVERS <[email protected]>; open list:IOMMU SUBSYSTEM <[email protected]>; open list <[email protected]>; opensource.kernel <[email protected]> 主题: Re: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()

Quoted 13 lines · Minjie Du

Make IS_ERR() judge the debugfs_create_dir() function return in tegra_smmu_debugfs_init()

---
 drivers/iommu/tegra-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/tegra-smmu.c +0 -0
index 1cbf063cc..841e14cce 100644

drivers/iommu/tegra-smmu.c DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients); · line 1059

Quoted 5 lines
drivers/iommu/tegra-smmu.c +1 -1
@@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
 static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)  {
 	smmu->debugfs = debugfs_create_dir("smmu", NULL);
-	if (!smmu->debugfs)
+	if (IS_ERR(smmu->debugfs))
 		return;

I think we can just drop the error check altogether since debugfs_create_file() will simply return early if smmu->debugfs is an error pointer.

Thierry

#3 lore raw
Quoted 7 lines · 杜敏杰

Hi Thierry!

Quoted 2 lines

I think we can just drop the error check altogether since debugfs_create_file() will simply return early if smmu->debugfs is an error pointer.

So do you mean maybe delete the smmu->debugfs check is better? Maybe I can resubmit a new patch.

Yes, I think that would be preferable.

Thierry

#4 lore raw
In reply to Thierry Reding

…

Quoted 4 lines
Quoted 4 lines

+++ b/drivers/iommu/tegra-smmu.c

drivers/iommu/tegra-smmu.c +0 -0
@@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
 static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
 {
Quoted 8 lines

drivers/iommu/tegra-smmu.c DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients); · line 1060

Quoted 4 lines
drivers/iommu/tegra-smmu.c +1 -1
 	smmu->debugfs = debugfs_create_dir("smmu", NULL);
-	if (!smmu->debugfs)
+	if (IS_ERR(smmu->debugfs))
 		return;

I think we can just drop the error check altogether since debugfs_create_file() will simply return early if smmu->debugfs is an error pointer.

I find this explanation confusing.
Can consistent error detection matter also at this source code place?

Regards,
Markus