diff options
author | Linus Lüssing <linus.luessing@web.de> | 2010-01-02 11:30:52 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-03 16:42:36 -0800 |
commit | 4230020c42457e51c98636a328c60e9f3744152c (patch) | |
tree | 7937cc25d83ffba16663d7583061e8528ff73734 /drivers/staging/batman-adv | |
parent | abad5446585b0b9519fad00c05156f373ea114ad (diff) |
Staging: batman-adv: Dont deactivate 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üssing <linus.luessing@web.de>
Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv')
-rw-r--r-- | 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 4d199351c2b..68c36b097a0 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; } |