Skip to contentSkip to conversation

iommu: Fix an error check in tegra_smmu_debugfs_init()

PATCH Superseded Minjie Du 2 participants 3 messages Jul 14, 2023 – Jul 17, 2023

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Minjie Du

author
#0 lore raw

PATCH v5 1/1 iommu: Fix an error check in tegra_smmu_debugfs_init()

debugfs_create_dir() function returns an error value(PTR_ERR). We need to evaluate the return value using IS_ERR, rather than checking for NULL.

Fixes d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")

---
V4 -> V5: debugfs needs to have error checking, so use IS_ERR() to error check. V3 -> V4: fix expression about patch.
V2 -> V3: fix expression about patch.
V1 -> V2: remove the error check.
V1: use IS_ERR() to error check.

---
 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 8 lines · Minjie Du

debugfs_create_dir() function returns an error value(PTR_ERR). We need to evaluate the return value using IS_ERR, rather than checking for NULL.

Fixes d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")

---
V4 -> V5: debugfs needs to have error checking, so use IS_ERR() to error check.

Why?

[...]
* NOTE: it's expected that most callers should _ignore_ the errors
returned
* by this function. Other debugfs functions handle the fact that the
"dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway. */
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)

{
        struct dentry *dentry = start_creating(name, parent);
        struct inode *inode;

        if (IS_ERR(dentry))
                return dentry;

[...]

Best regards,
baolu

author
#2 lore raw

Hi Baolu!

I'm so sorry, I made a mistake.
The patch :
'[PATCH v5] iommu: Fix an error check in tegra_smmu_debugfs_init()' This is a wrong patch, shoule be should be discarded.

I submitted [patch v6], This is the correct patch. Sorry again for my mistake.
Thanks!

regards,
Minjie

-----邮件原件-----
发件人: Baolu Lu <[email protected]>
发送时间: 2023年7月15日 14:26
收件人: 杜敏杰 <[email protected]>; Thierry Reding <[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]> 抄送: [email protected]; opensource.kernel <[email protected]>
主题: Re: [PATCH v5] iommu: Fix an error check in tegra_smmu_debugfs_init()

[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 8 lines · Minjie Du

debugfs_create_dir() function returns an error value(PTR_ERR). We need to evaluate the return value using IS_ERR, rather than checking for NULL.

Fixes d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")

---
V4 -> V5: debugfs needs to have error checking, so use IS_ERR() to error check.

Why?

[...]
* NOTE: it's expected that most callers should _ignore_ the errors returned
* by this function. Other debugfs functions handle the fact that the "dentry"
* passed to them could be an error and they don't crash in that case.
* Drivers should generally work fine even if debugfs fails to init anyway. */

struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) {
         struct dentry *dentry = start_creating(name, parent);
         struct inode *inode;

         if (IS_ERR(dentry))
                 return dentry;

[...]

Best regards,
baolu