Author: simon Date: 2010-01-01 18:13:27 +0100 (Fri, 01 Jan 2010) New Revision: 1528
Modified: trunk/batman-adv-kernelland/proc.c Log: batman-adv: No deact of aggregation on wrong input
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?\195?\188ssing linus.luessing@web.de Acked-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de
Modified: trunk/batman-adv-kernelland/proc.c =================================================================== --- trunk/batman-adv-kernelland/proc.c 2010-01-01 16:56:10 UTC (rev 1527) +++ trunk/batman-adv-kernelland/proc.c 2010-01-01 17:13:27 UTC (rev 1528) @@ -428,6 +428,7 @@ char *aggr_string; int not_copied = 0; unsigned long aggregation_enabled_tmp; + int retval;
aggr_string = kmalloc(count, GFP_KERNEL);
@@ -437,22 +438,21 @@ 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; }