iommu: fix parameter check in tegra_smmu_debugfs_init()
Subsystems (3)
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
@@ -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
Quoted 13 lines · Minjie Du
Make
IS_ERR()judge thedebugfs_create_dir()function return integra_smmu_debugfs_init()Signed-off-by Minjie Du <[email protected]>--- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/tegra-smmu.c +0
-0
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
Hi Thierry!
Quoted 2 lines
I think we can just drop the error check altogether since
debugfs_create_file()will simply return early ifsmmu->debugfsis 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 thedebugfs_create_dir()function return integra_smmu_debugfs_init()Signed-off-by Minjie Du <[email protected]>--- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/tegra-smmu.c +0
-0
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
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 ifsmmu->debugfsis an error pointer.So do you mean maybe delete the
smmu->debugfscheck is better? Maybe I can resubmit a new patch.
Yes, I think that would be preferable.
Thierry
…
Quoted 4 lines
Quoted 4 lines
+++
b/drivers/iommu/tegra-smmu.cdrivers/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
-1smmu->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 ifsmmu->debugfsis an error pointer.
I find this explanation confusing.
Can consistent error detection matter also at this source code place?
Regards,
Markus