diff options
author | Cong Wang <amwang@redhat.com> | 2013-01-27 16:14:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-29 15:43:03 -0500 |
commit | 604dfd6efc9b79bce432f2394791708d8e8f6efc (patch) | |
tree | 9c3b1021318026f9300d51e6340271946d046b8f /net/core/pktgen.c | |
parent | a13d3104710184ecc43edc35a25ae8092058463f (diff) |
pktgen: correctly handle failures when adding a device
The return value of pktgen_add_device() is not checked, so
even if we fail to add some device, for example, non-exist one,
we still see "OK:...". This patch fixes it.
After this patch, I got:
# echo "add_device non-exist" > /proc/net/pktgen/kpktgend_0
-bash: echo: write error: No such device
# cat /proc/net/pktgen/kpktgend_0
Running:
Stopped:
Result: ERROR: can not add device non-exist
# echo "add_device eth0" > /proc/net/pktgen/kpktgend_0
# cat /proc/net/pktgen/kpktgend_0
Running:
Stopped: eth0
Result: OK: add_device=eth0
(Candidate for -stable)
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r-- | net/core/pktgen.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index b29dacf900f9..e6e1cbe863f5 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -1781,10 +1781,13 @@ static ssize_t pktgen_thread_write(struct file *file, | |||
1781 | return -EFAULT; | 1781 | return -EFAULT; |
1782 | i += len; | 1782 | i += len; |
1783 | mutex_lock(&pktgen_thread_lock); | 1783 | mutex_lock(&pktgen_thread_lock); |
1784 | pktgen_add_device(t, f); | 1784 | ret = pktgen_add_device(t, f); |
1785 | mutex_unlock(&pktgen_thread_lock); | 1785 | mutex_unlock(&pktgen_thread_lock); |
1786 | ret = count; | 1786 | if (!ret) { |
1787 | sprintf(pg_result, "OK: add_device=%s", f); | 1787 | ret = count; |
1788 | sprintf(pg_result, "OK: add_device=%s", f); | ||
1789 | } else | ||
1790 | sprintf(pg_result, "ERROR: can not add device %s", f); | ||
1788 | goto out; | 1791 | goto out; |
1789 | } | 1792 | } |
1790 | 1793 | ||