Commit 9ee1942c authored by Prashant Bhole's avatar Prashant Bhole Committed by David S. Miller

netdevsim: correctly check return value of debugfs_create_dir

- Checking return value with IS_ERROR_OR_NULL
- Added error handling where it was not handled
Signed-off-by: default avatarPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent afb4c97d
...@@ -198,7 +198,6 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog) ...@@ -198,7 +198,6 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog)
{ {
struct nsim_bpf_bound_prog *state; struct nsim_bpf_bound_prog *state;
char name[16]; char name[16];
int err;
state = kzalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
...@@ -211,10 +210,9 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog) ...@@ -211,10 +210,9 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog)
/* Program id is not populated yet when we create the state. */ /* Program id is not populated yet when we create the state. */
sprintf(name, "%u", ns->prog_id_gen++); sprintf(name, "%u", ns->prog_id_gen++);
state->ddir = debugfs_create_dir(name, ns->ddir_bpf_bound_progs); state->ddir = debugfs_create_dir(name, ns->ddir_bpf_bound_progs);
if (IS_ERR(state->ddir)) { if (IS_ERR_OR_NULL(state->ddir)) {
err = PTR_ERR(state->ddir);
kfree(state); kfree(state);
return err; return -ENOMEM;
} }
debugfs_create_u32("id", 0400, state->ddir, &prog->aux->id); debugfs_create_u32("id", 0400, state->ddir, &prog->aux->id);
...@@ -346,6 +344,8 @@ int nsim_bpf_init(struct netdevsim *ns) ...@@ -346,6 +344,8 @@ int nsim_bpf_init(struct netdevsim *ns)
&ns->bpf_bind_verifier_delay); &ns->bpf_bind_verifier_delay);
ns->ddir_bpf_bound_progs = ns->ddir_bpf_bound_progs =
debugfs_create_dir("bpf_bound_progs", ns->ddir); debugfs_create_dir("bpf_bound_progs", ns->ddir);
if (IS_ERR_OR_NULL(ns->ddir_bpf_bound_progs))
return -ENOMEM;
ns->bpf_tc_accept = true; ns->bpf_tc_accept = true;
debugfs_create_bool("bpf_tc_accept", 0600, ns->ddir, debugfs_create_bool("bpf_tc_accept", 0600, ns->ddir,
......
...@@ -151,6 +151,8 @@ static int nsim_init(struct net_device *dev) ...@@ -151,6 +151,8 @@ static int nsim_init(struct net_device *dev)
ns->netdev = dev; ns->netdev = dev;
ns->ddir = debugfs_create_dir(netdev_name(dev), nsim_ddir); ns->ddir = debugfs_create_dir(netdev_name(dev), nsim_ddir);
if (IS_ERR_OR_NULL(ns->ddir))
return -ENOMEM;
err = nsim_bpf_init(ns); err = nsim_bpf_init(ns);
if (err) if (err)
...@@ -469,8 +471,8 @@ static int __init nsim_module_init(void) ...@@ -469,8 +471,8 @@ static int __init nsim_module_init(void)
int err; int err;
nsim_ddir = debugfs_create_dir(DRV_NAME, NULL); nsim_ddir = debugfs_create_dir(DRV_NAME, NULL);
if (IS_ERR(nsim_ddir)) if (IS_ERR_OR_NULL(nsim_ddir))
return PTR_ERR(nsim_ddir); return -ENOMEM;
err = bus_register(&nsim_bus); err = bus_register(&nsim_bus);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment