2023-05-12 20:54:04

by SikkiLadho

[permalink] [raw]
Subject: [PATCH] net: marvell: fix error checking for debugfs

This commit fixes error checking in by using IS_ERR inline function to
check for errors.

Suggested-by: Ivan Orlov <[email protected]>
Signed-off-by: SikkiLadho <[email protected]>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
index 75e83ea2a..9c53f378e 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
@@ -593,7 +593,7 @@ static int mvpp2_dbgfs_c2_entry_init(struct dentry *parent,
sprintf(c2_entry_name, "%03d", id);

c2_entry_dir = debugfs_create_dir(c2_entry_name, parent);
- if (!c2_entry_dir)
+ if (IS_ERR(c2_entry_dir))
return -ENOMEM;

entry = &priv->dbgfs_entries->c2_entries[id];
@@ -626,7 +626,7 @@ static int mvpp2_dbgfs_flow_tbl_entry_init(struct dentry *parent,
sprintf(flow_tbl_entry_name, "%03d", id);

flow_tbl_entry_dir = debugfs_create_dir(flow_tbl_entry_name, parent);
- if (!flow_tbl_entry_dir)
+ if (IS_ERR(flow_tbl_entry_dir))
return -ENOMEM;

entry = &priv->dbgfs_entries->flt_entries[id];
@@ -646,11 +646,11 @@ static int mvpp2_dbgfs_cls_init(struct dentry *parent, struct mvpp2 *priv)
int i, ret;

cls_dir = debugfs_create_dir("classifier", parent);
- if (!cls_dir)
+ if (IS_ERR(cls_dir))
return -ENOMEM;

c2_dir = debugfs_create_dir("c2", cls_dir);
- if (!c2_dir)
+ if (IS_ERR(c2_dir))
return -ENOMEM;

for (i = 0; i < MVPP22_CLS_C2_N_ENTRIES; i++) {
@@ -660,7 +660,7 @@ static int mvpp2_dbgfs_cls_init(struct dentry *parent, struct mvpp2 *priv)
}

flow_tbl_dir = debugfs_create_dir("flow_table", cls_dir);
- if (!flow_tbl_dir)
+ if (IS_ERR(flow_tbl_dir))
return -ENOMEM;

for (i = 0; i < MVPP2_CLS_FLOWS_TBL_SIZE; i++) {
--
2.38.1



2023-05-13 10:33:46

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH] net: marvell: fix error checking for debugfs

On Sat, May 13, 2023 at 06:46:28AM +0500, SikkiLadho wrote:
> This commit fixes error checking in by using IS_ERR inline function to
> check for errors.
>
> Suggested-by: Ivan Orlov <[email protected]>
> Signed-off-by: SikkiLadho <[email protected]>

The modern wisdom for debugfs is not to check for any errors, so if
we're going to touch this, that's the route that any patch should be
taking.

Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!