From patchwork Thu Dec 31 03:39:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 5208 Return-Path: Received: from fmmailgate03.web.de (fmmailgate03.web.de [217.72.192.234]) by open-mesh.net (Postfix) with ESMTP id 1367815408A for ; Thu, 31 Dec 2009 03:57:34 +0000 (UTC) Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate03.web.de (Postfix) with ESMTP id 9927B13B09559 for ; Thu, 31 Dec 2009 04:39:55 +0100 (CET) Received: from [85.179.239.35] (helo=localhost) by smtp06.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #314) id 1NQBtD-00074R-00 for b.a.t.m.a.n@lists.open-mesh.net; Thu, 31 Dec 2009 04:39:55 +0100 Date: Thu, 31 Dec 2009 04:39:55 +0100 From: =?utf-8?B?PT9VVEYtOD9xP0xpbnVzPTIwTD1DMz1CQ3NzaW5nPz0=?= To: b.a.t.m.a.n@lists.open-mesh.net Message-ID: <20091231033955.GB18781@Sellars> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX18JHvcU9c/O/Q9hY+myWa0N/Ex/vH4EQLqBydlu Z+6BgKnfI6epkDflcQjvCqrthv+BHzky9Pasbj1l7i12p9uSpE wWUjAnakWisCoN3sQXrA== Subject: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: No deact of aggregation on wrong input X-BeenThere: b.a.t.m.a.n@lists.open-mesh.net X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Dec 2009 03:57:35 -0000 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 --- proc.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/proc.c b/proc.c index e7b7bf3..232efe3 100644 --- a/proc.c +++ b/proc.c @@ -433,6 +433,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); @@ -442,22 +443,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 == -EINVAL || 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; }