All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/tegra-smmu: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
@ 2023-08-31 12:38 Jinjie Ruan
  2023-09-01  3:05 ` Baolu Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Jinjie Ruan @ 2023-08-31 12:38 UTC (permalink / raw)
  To: linux-tegra, iommu, Thierry Reding, Krishna Reddy, Joerg Roedel,
	Will Deacon, Robin Murphy, Jonathan Hunter
  Cc: ruanjinjie

The debugfs_create_dir() function returns error pointers.
It never returns NULL. So use IS_ERR() to check it.

Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 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 e445f80d0226..cd1d80c4c673 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.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/tegra-smmu: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
  2023-08-31 12:38 [PATCH] iommu/tegra-smmu: Fix the NULL vs IS_ERR() bug for debugfs_create_dir() Jinjie Ruan
@ 2023-09-01  3:05 ` Baolu Lu
  2023-09-06 13:36   ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Baolu Lu @ 2023-09-01  3:05 UTC (permalink / raw)
  To: Jinjie Ruan, linux-tegra, iommu, Thierry Reding, Krishna Reddy,
	Joerg Roedel, Will Deacon, Robin Murphy, Jonathan Hunter
  Cc: baolu.lu

On 2023/8/31 20:38, Jinjie Ruan wrote:
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL. So use IS_ERR() to check it.
> 
> Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>   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 e445f80d0226..cd1d80c4c673 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;

There is no need to check the return value of debugfs_create_dir(). This
change cannot fix anything as far as I can see. Just remove the check.

>   
>   	debugfs_create_file("swgroups", S_IRUGO, smmu->debugfs, smmu,

Best regards,
baolu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/tegra-smmu: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
  2023-09-01  3:05 ` Baolu Lu
@ 2023-09-06 13:36   ` Jason Gunthorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2023-09-06 13:36 UTC (permalink / raw)
  To: Baolu Lu
  Cc: Jinjie Ruan, linux-tegra, iommu, Thierry Reding, Krishna Reddy,
	Joerg Roedel, Will Deacon, Robin Murphy, Jonathan Hunter

On Fri, Sep 01, 2023 at 11:05:48AM +0800, Baolu Lu wrote:
> On 2023/8/31 20:38, Jinjie Ruan wrote:
> > The debugfs_create_dir() function returns error pointers.
> > It never returns NULL. So use IS_ERR() to check it.
> > 
> > Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
> > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> > ---
> >   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 e445f80d0226..cd1d80c4c673 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;
> 
> There is no need to check the return value of debugfs_create_dir(). This
> change cannot fix anything as far as I can see. Just remove the
> check.

Right

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-06 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31 12:38 [PATCH] iommu/tegra-smmu: Fix the NULL vs IS_ERR() bug for debugfs_create_dir() Jinjie Ruan
2023-09-01  3:05 ` Baolu Lu
2023-09-06 13:36   ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.