Commit 09455747 authored by Mathias Krause's avatar Mathias Krause Committed by David S. Miller

pktgen: simplify error handling in pgctrl_write()

The 'out' label is just a relict from previous times as pgctrl_write()
had multiple error paths. Get rid of it and simply return right away
on errors.

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 20b0c718
...@@ -476,14 +476,11 @@ static int pgctrl_show(struct seq_file *seq, void *v) ...@@ -476,14 +476,11 @@ static int pgctrl_show(struct seq_file *seq, void *v)
static ssize_t pgctrl_write(struct file *file, const char __user *buf, static ssize_t pgctrl_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
int err = 0;
char data[128]; char data[128];
struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id); struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id);
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN))
err = -EPERM; return -EPERM;
goto out;
}
if (count == 0) if (count == 0)
return -EINVAL; return -EINVAL;
...@@ -491,10 +488,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, ...@@ -491,10 +488,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf,
if (count > sizeof(data)) if (count > sizeof(data))
count = sizeof(data); count = sizeof(data);
if (copy_from_user(data, buf, count)) { if (copy_from_user(data, buf, count))
err = -EFAULT; return -EFAULT;
goto out;
}
data[count - 1] = 0; /* Strip trailing '\n' and terminate string */ data[count - 1] = 0; /* Strip trailing '\n' and terminate string */
if (!strcmp(data, "stop")) if (!strcmp(data, "stop"))
...@@ -509,10 +505,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, ...@@ -509,10 +505,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf,
else else
pr_warning("Unknown command: %s\n", data); pr_warning("Unknown command: %s\n", data);
err = count; return count;
out:
return err;
} }
static int pgctrl_open(struct inode *inode, struct file *file) static int pgctrl_open(struct inode *inode, struct file *file)
......
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