b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: gregkh@suse.de
Cc: b.a.t.m.a.n@lists.open-mesh.net
Subject: [B.A.T.M.A.N.] [PATCH 17/17] Staging: batman-adv: Dont deactivate aggregation on wrong input
Date: Sat,  2 Jan 2010 11:30:52 +0100	[thread overview]
Message-ID: <1262428252-26439-17-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1262428252-26439-16-git-send-email-andrew@lunn.ch>

From: Linus Lüssing <linus.luessing@web.de>

A non-integer changes the aggregation mode. Therefore this patch changes
the behaviour to explicitly check strict_strtoul()'s return code.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/staging/batman-adv/proc.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/batman-adv/proc.c b/drivers/staging/batman-adv/proc.c
index 6a7c8bb..2aeee7a 100644
--- a/drivers/staging/batman-adv/proc.c
+++ b/drivers/staging/batman-adv/proc.c
@@ -427,6 +427,7 @@ static ssize_t proc_aggr_write(struct file *file, const char __user *buffer,
 	char *aggr_string;
 	int not_copied = 0;
 	unsigned long aggregation_enabled_tmp;
+	int retval;
 
 	aggr_string = kmalloc(count, GFP_KERNEL);
 
@@ -436,22 +437,21 @@ static ssize_t proc_aggr_write(struct file *file, const char __user *buffer,
 	not_copied = copy_from_user(aggr_string, buffer, count);
 	aggr_string[count - not_copied - 1] = 0;
 
-	strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp);
+	retval = strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp);
 
-	if ((aggregation_enabled_tmp != 0) && (aggregation_enabled_tmp != 1)) {
+	if (retval || aggregation_enabled_tmp > 1) {
 		printk(KERN_ERR "batman-adv:Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp);
-		goto end;
+	} else {
+		printk(KERN_INFO "batman-adv:Changing aggregation from: %s (%i) to: %s (%li)\n",
+		       (atomic_read(&aggregation_enabled) == 1 ?
+			"enabled" : "disabled"),
+		       atomic_read(&aggregation_enabled),
+		       (aggregation_enabled_tmp == 1 ? "enabled" : "disabled"),
+		       aggregation_enabled_tmp);
+		atomic_set(&aggregation_enabled,
+			   (unsigned)aggregation_enabled_tmp);
 	}
 
-	printk(KERN_INFO "batman-adv:Changing aggregation from: %s (%i) to: %s (%li)\n",
-	       (atomic_read(&aggregation_enabled) == 1 ?
-		"enabled" : "disabled"),
-	       atomic_read(&aggregation_enabled),
-	       (aggregation_enabled_tmp == 1 ? "enabled" : "disabled"),
-	       aggregation_enabled_tmp);
-
-	atomic_set(&aggregation_enabled, (unsigned)aggregation_enabled_tmp);
-end:
 	kfree(aggr_string);
 	return count;
 }
-- 
1.6.5.7


  reply	other threads:[~2010-01-02 10:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-02 10:30 [B.A.T.M.A.N.] [PATCH 01/17] Staging: batman-adv: Remove NULL pointer check Andrew Lunn
2010-01-02 10:30 ` [B.A.T.M.A.N.] [PATCH 02/17] Staging: batman-adv: update README for latest kernel Andrew Lunn
2010-01-02 10:30   ` [B.A.T.M.A.N.] [PATCH 03/17] Staging: batman-adv: Replace KERN_DEBUG with bat_dbg Andrew Lunn
2010-01-02 10:30     ` [B.A.T.M.A.N.] [PATCH 04/17] Staging: batman-adv: initialize static hash iterators Andrew Lunn
2010-01-02 10:30       ` [B.A.T.M.A.N.] [PATCH 05/17] Staging: batman-adv: consistent spelling of "neighbors" Andrew Lunn
2010-01-02 10:30         ` [B.A.T.M.A.N.] [PATCH 06/17] Staging: batman-adv: Use forw_bcast_list_lock always with disabled interrupts Andrew Lunn
2010-01-02 10:30           ` [B.A.T.M.A.N.] [PATCH 07/17] Staging: batman-adv: Fixes rounding issues in vis.c Andrew Lunn
2010-01-02 10:30             ` [B.A.T.M.A.N.] [PATCH 08/17] Staging: batman-adv: fix minor orig table layout bug Andrew Lunn
2010-01-02 10:30               ` [B.A.T.M.A.N.] [PATCH 09/17] Staging: batman-adv: moving vis output formats out of the kernel Andrew Lunn
2010-01-02 10:30                 ` [B.A.T.M.A.N.] [PATCH 10/17] Staging: batman-adv: remove obsoleted vis_format /proc file Andrew Lunn
2010-01-02 10:30                   ` [B.A.T.M.A.N.] [PATCH 11/17] Staging: batman-adv: splitting /proc vis file into vis_server and vis_data Andrew Lunn
2010-01-02 10:30                     ` [B.A.T.M.A.N.] [PATCH 12/17] Staging: batman-adv: check all kmalloc()s Andrew Lunn
2010-01-02 10:30                       ` [B.A.T.M.A.N.] [PATCH 13/17] Staging: batman-adv: receive packets directly using skbs Andrew Lunn
2010-01-02 10:30                         ` [B.A.T.M.A.N.] [PATCH 14/17] Staging: batman-adv: Allow the MAC address to be set Andrew Lunn
2010-01-02 10:30                           ` [B.A.T.M.A.N.] [PATCH 15/17] Staging: batman-adv: Use printk(%pM) for MAC addresses Andrew Lunn
2010-01-02 10:30                             ` [B.A.T.M.A.N.] [PATCH 16/17] Staging: batman-adv: Remove compat.h Andrew Lunn
2010-01-02 10:30                               ` Andrew Lunn [this message]
2010-01-05 22:40   ` [B.A.T.M.A.N.] [PATCH 02/17] Staging: batman-adv: update README for latest kernel Greg KH
2010-01-06  6:22     ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1262428252-26439-17-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.net \
    --cc=gregkh@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).