]> git.itanic.dy.fi Git - linux-stable/commitdiff
mvpp2: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 10 Aug 2019 10:17:28 +0000 (12:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:02:52 +0000 (11:02 +0200)
[ Upstream commit e6882aa623f6fe0d80fa82ebf3ee78c353bffbe1 ]

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nathan Huckleberry <nhuck@google.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: fe2c9c61f668 ("net: mvpp2: debugfs: fix memory leak when using debugfs_lookup()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c

index f9744a61e5dd6fc6282eddca38b2718dac899e12..87d9cbe10cec1800acdd8fd83ea32a973344cf89 100644 (file)
@@ -484,8 +484,6 @@ static int mvpp2_dbgfs_flow_port_init(struct dentry *parent,
        struct dentry *port_dir;
 
        port_dir = debugfs_create_dir(port->dev->name, parent);
-       if (IS_ERR(port_dir))
-               return PTR_ERR(port_dir);
 
        /* This will be freed by 'hash_opts' release op */
        port_entry = kmalloc(sizeof(*port_entry), GFP_KERNEL);
@@ -515,8 +513,6 @@ static int mvpp2_dbgfs_flow_entry_init(struct dentry *parent,
        sprintf(flow_entry_name, "%02d", flow);
 
        flow_entry_dir = debugfs_create_dir(flow_entry_name, parent);
-       if (!flow_entry_dir)
-               return -ENOMEM;
 
        /* This will be freed by 'type' release op */
        entry = kmalloc(sizeof(*entry), GFP_KERNEL);
@@ -554,8 +550,6 @@ static int mvpp2_dbgfs_flow_init(struct dentry *parent, struct mvpp2 *priv)
        int i, ret;
 
        flow_dir = debugfs_create_dir("flows", parent);
-       if (!flow_dir)
-               return -ENOMEM;
 
        for (i = 0; i < MVPP2_N_FLOWS; i++) {
                ret = mvpp2_dbgfs_flow_entry_init(flow_dir, priv, i);
@@ -579,8 +573,6 @@ static int mvpp2_dbgfs_prs_entry_init(struct dentry *parent,
        sprintf(prs_entry_name, "%03d", tid);
 
        prs_entry_dir = debugfs_create_dir(prs_entry_name, parent);
-       if (!prs_entry_dir)
-               return -ENOMEM;
 
        /* The 'valid' entry's ops will free that */
        entry = kmalloc(sizeof(*entry), GFP_KERNEL);
@@ -618,8 +610,6 @@ static int mvpp2_dbgfs_prs_init(struct dentry *parent, struct mvpp2 *priv)
        int i, ret;
 
        prs_dir = debugfs_create_dir("parser", parent);
-       if (!prs_dir)
-               return -ENOMEM;
 
        for (i = 0; i < MVPP2_PRS_TCAM_SRAM_SIZE; i++) {
                ret = mvpp2_dbgfs_prs_entry_init(prs_dir, priv, i);
@@ -636,8 +626,6 @@ static int mvpp2_dbgfs_port_init(struct dentry *parent,
        struct dentry *port_dir;
 
        port_dir = debugfs_create_dir(port->dev->name, parent);
-       if (IS_ERR(port_dir))
-               return PTR_ERR(port_dir);
 
        debugfs_create_file("parser_entries", 0444, port_dir, port,
                            &mvpp2_dbgfs_port_parser_fops);
@@ -671,15 +659,10 @@ void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name)
        int ret, i;
 
        mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL);
-       if (!mvpp2_root) {
+       if (!mvpp2_root)
                mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL);
-               if (IS_ERR(mvpp2_root))
-                       return;
-       }
 
        mvpp2_dir = debugfs_create_dir(name, mvpp2_root);
-       if (IS_ERR(mvpp2_dir))
-               return;
 
        priv->dbgfs_dir = mvpp2_dir;