diff options
author | Mathias Krause <minipli@googlemail.com> | 2014-02-21 15:38:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-24 18:54:26 -0500 |
commit | 0945574750f3040a2309d960a569215598a64672 (patch) | |
tree | daccd26d3c144a5a1fa81b157a365b4a407aa45e /net | |
parent | 20b0c718c3bb122107bebadbb8ecf4bab76fb392 (diff) |
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: Mathias Krause <minipli@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/pktgen.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index cc07c434948a..53c30971172a 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -476,14 +476,11 @@ static int pgctrl_show(struct seq_file *seq, void *v) | |||
476 | static ssize_t pgctrl_write(struct file *file, const char __user *buf, | 476 | static ssize_t pgctrl_write(struct file *file, const char __user *buf, |
477 | size_t count, loff_t *ppos) | 477 | size_t count, loff_t *ppos) |
478 | { | 478 | { |
479 | int err = 0; | ||
480 | char data[128]; | 479 | char data[128]; |
481 | struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id); | 480 | struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id); |
482 | 481 | ||
483 | if (!capable(CAP_NET_ADMIN)) { | 482 | if (!capable(CAP_NET_ADMIN)) |
484 | err = -EPERM; | 483 | return -EPERM; |
485 | goto out; | ||
486 | } | ||
487 | 484 | ||
488 | if (count == 0) | 485 | if (count == 0) |
489 | return -EINVAL; | 486 | return -EINVAL; |
@@ -491,10 +488,9 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, | |||
491 | if (count > sizeof(data)) | 488 | if (count > sizeof(data)) |
492 | count = sizeof(data); | 489 | count = sizeof(data); |
493 | 490 | ||
494 | if (copy_from_user(data, buf, count)) { | 491 | if (copy_from_user(data, buf, count)) |
495 | err = -EFAULT; | 492 | return -EFAULT; |
496 | goto out; | 493 | |
497 | } | ||
498 | data[count - 1] = 0; /* Strip trailing '\n' and terminate string */ | 494 | data[count - 1] = 0; /* Strip trailing '\n' and terminate string */ |
499 | 495 | ||
500 | if (!strcmp(data, "stop")) | 496 | if (!strcmp(data, "stop")) |
@@ -509,10 +505,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf, | |||
509 | else | 505 | else |
510 | pr_warning("Unknown command: %s\n", data); | 506 | pr_warning("Unknown command: %s\n", data); |
511 | 507 | ||
512 | err = count; | 508 | return count; |
513 | |||
514 | out: | ||
515 | return err; | ||
516 | } | 509 | } |
517 | 510 | ||
518 | static int pgctrl_open(struct inode *inode, struct file *file) | 511 | static int pgctrl_open(struct inode *inode, struct file *file) |