2023-07-12 12:13:35

by Minjie Du

[permalink] [raw]
Subject: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()

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

Signed-off-by: Minjie Du <[email protected]>
---
drivers/iommu/tegra-smmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 1cbf063cc..841e14cce 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -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,
--
2.39.0



2023-07-12 12:55:18

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()

On Wed, Jul 12, 2023 at 07:31:45PM +0800, Minjie Du wrote:
> Make IS_ERR() judge the debugfs_create_dir() function return
> in tegra_smmu_debugfs_init()
>
> Signed-off-by: Minjie Du <[email protected]>
> ---
> drivers/iommu/tegra-smmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index 1cbf063cc..841e14cce 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -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


Attachments:
(No filename) (912.00 B)
signature.asc (849.00 B)
Download all attachments