From patchwork Fri Feb 15 03:10:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3.5.y.z, extended, stable] Patch "pktgen: correctly handle failures when adding a device" has been added to staging queue Date: Thu, 14 Feb 2013 17:10:59 -0000 From: Herton Ronaldo Krzesinski X-Patchwork-Id: 220601 Message-Id: <1360897859-15728-1-git-send-email-herton.krzesinski@canonical.com> To: Cong Wang Cc: kernel-team@lists.ubuntu.com, "David S. Miller" This is a note to let you know that I have just added a patch titled pktgen: correctly handle failures when adding a device to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.5.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Herton ------ >From b2afb91d32432821bd73f7a184ec112d84a8af4f Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Sun, 27 Jan 2013 21:14:08 +0000 Subject: [PATCH] pktgen: correctly handle failures when adding a device commit 604dfd6efc9b79bce432f2394791708d8e8f6efc upstream. 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 Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Herton Ronaldo Krzesinski --- net/core/pktgen.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 1.7.9.5 diff --git a/net/core/pktgen.c b/net/core/pktgen.c index aa278cd..2a42802 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -1797,10 +1797,13 @@ static ssize_t pktgen_thread_write(struct file *file, return -EFAULT; i += len; mutex_lock(&pktgen_thread_lock); - pktgen_add_device(t, f); + ret = pktgen_add_device(t, f); mutex_unlock(&pktgen_thread_lock); - ret = count; - sprintf(pg_result, "OK: add_device=%s", f); + if (!ret) { + ret = count; + sprintf(pg_result, "OK: add_device=%s", f); + } else + sprintf(pg_result, "ERROR: can not add device %s", f); goto out; }