All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()
@ 2023-07-12 11:31 Minjie Du
  2023-07-12 12:22 ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Minjie Du @ 2023-07-12 11:31 UTC (permalink / raw)
  To: Thierry Reding, Krishna Reddy, Joerg Roedel, Will Deacon,
	Robin Murphy, Jonathan Hunter, open list:TEGRA IOMMU DRIVERS,
	open list:IOMMU SUBSYSTEM, open list
  Cc: opensource.kernel, Minjie Du

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

Signed-off-by: Minjie Du <duminjie@vivo.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 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


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

* Re: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()
  2023-07-12 11:31 [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init() Minjie Du
@ 2023-07-12 12:22 ` Thierry Reding
  2023-07-12 12:37   ` 回复: " 杜敏杰
  2023-07-12 16:02   ` [PATCH] " Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Thierry Reding @ 2023-07-12 12:22 UTC (permalink / raw)
  To: Minjie Du
  Cc: Krishna Reddy, Joerg Roedel, Will Deacon, Robin Murphy,
	Jonathan Hunter, open list:TEGRA IOMMU DRIVERS,
	open list:IOMMU SUBSYSTEM, open list, opensource.kernel

[-- Attachment #1: Type: text/plain, Size: 912 bytes --]

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 <duminjie@vivo.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 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* 回复: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()
  2023-07-12 12:22 ` Thierry Reding
@ 2023-07-12 12:37   ` 杜敏杰
  2023-07-12 15:06     ` Thierry Reding
  2023-07-12 16:02   ` [PATCH] " Markus Elfring
  1 sibling, 1 reply; 5+ messages in thread
From: 杜敏杰 @ 2023-07-12 12:37 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Krishna Reddy, Joerg Roedel, Will Deacon, Robin Murphy,
	Jonathan Hunter, open list:TEGRA IOMMU DRIVERS,
	open list:IOMMU SUBSYSTEM, open list, opensource.kernel

Hi Thierry!

>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 <thierry.reding@gmail.com> 
发送时间: 2023年7月12日 20:22
收件人: 杜敏杰 <duminjie@vivo.com>
抄送: Krishna Reddy <vdumpa@nvidia.com>; Joerg Roedel <joro@8bytes.org>; Will Deacon <will@kernel.org>; Robin Murphy <robin.murphy@arm.com>; Jonathan Hunter <jonathanh@nvidia.com>; open list:TEGRA IOMMU DRIVERS <linux-tegra@vger.kernel.org>; open list:IOMMU SUBSYSTEM <iommu@lists.linux.dev>; open list <linux-kernel@vger.kernel.org>; opensource.kernel <opensource.kernel@vivo.com>
主题: 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 <duminjie@vivo.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 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

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

* Re: 回复: [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init()
  2023-07-12 12:37   ` 回复: " 杜敏杰
@ 2023-07-12 15:06     ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2023-07-12 15:06 UTC (permalink / raw)
  To: 杜敏杰
  Cc: Krishna Reddy, Joerg Roedel, Will Deacon, Robin Murphy,
	Jonathan Hunter, open list:TEGRA IOMMU DRIVERS,
	open list:IOMMU SUBSYSTEM, open list, opensource.kernel

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

On Wed, Jul 12, 2023 at 12:37:02PM +0000, 杜敏杰 wrote:
> Hi Thierry!
> 
> >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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] iommu: fix parameter check in tegra_smmu_debugfs_init()
  2023-07-12 12:22 ` Thierry Reding
  2023-07-12 12:37   ` 回复: " 杜敏杰
@ 2023-07-12 16:02   ` Markus Elfring
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2023-07-12 16:02 UTC (permalink / raw)
  To: Thierry Reding, Minjie Du, linux-tegra, kernel-janitors, iommu,
	Jörg Rödel, Jonathan Hunter, Krishna Reddy,
	Robin Murphy, Will Deacon
  Cc: opensource.kernel, LKML

…
> > +++ 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.

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

Regards,
Markus

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

end of thread, other threads:[~2023-07-12 16:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 11:31 [PATCH v1] iommu: fix parameter check in tegra_smmu_debugfs_init() Minjie Du
2023-07-12 12:22 ` Thierry Reding
2023-07-12 12:37   ` 回复: " 杜敏杰
2023-07-12 15:06     ` Thierry Reding
2023-07-12 16:02   ` [PATCH] " Markus Elfring

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.