* [PATCH] kernel/param.c: don't use .max when .num is NULL in param_array_set()
@ 2005-03-27 12:57 Bert Wesarg
2005-03-29 6:05 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: Bert Wesarg @ 2005-03-27 12:57 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel
Hello,
there seems to be a bug, at least for me, in kernel/param.c for arrays
with .num == NULL. If .num == NULL, the function param_array_set() uses
&.max for the call to param_array(), wich alters the .max value to the
number of arguments. The result is, you can't set more array arguments as
the last time you set the parameter.
example:
# a module 'example' with
# static int array[10] = { 0, };
# module_param_array(array, int, NULL, 0644);
$ insmod example.ko array=1,2,3
$ cat /sys/module/example/parameters/array
1,2,3
$ echo "4,3,2,1" > /sys/module/example/parameters/array
$ dmesg | tail -n 1
kernel: array: can take only 3 arguments
Patch is against 2.6.12-rc1.
Signed-off-by: Bert Wesarg <wesarg@informatik.uni-halle.de>
--- linux-2.6.12-rc1.orig/kernel/params.c 2005-03-27 14:44:00.000000000 +0200
+++ linux-2.6.12-rc1/kernel/params.c 2005-03-27 14:45:55.000000000 +0200
@@ -314,9 +314,10 @@ int param_array(const char *name,
int param_array_set(const char *val, struct kernel_param *kp)
{
struct kparam_array *arr = kp->arg;
+ unsigned int temp_num;
return param_array(kp->name, val, 1, arr->max, arr->elem,
- arr->elemsize, arr->set, arr->num ?: &arr->max);
+ arr->elemsize, arr->set, arr->num ?: &temp_num);
}
int param_array_get(char *buffer, struct kernel_param *kp)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] kernel/param.c: don't use .max when .num is NULL in param_array_set()
2005-03-27 12:57 [PATCH] kernel/param.c: don't use .max when .num is NULL in param_array_set() Bert Wesarg
@ 2005-03-29 6:05 ` Rusty Russell
2005-03-29 10:07 ` Bert Wesarg
0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2005-03-29 6:05 UTC (permalink / raw)
To: Bert Wesarg; +Cc: lkml - Kernel Mailing List
On Sun, 2005-03-27 at 14:57 +0200, Bert Wesarg wrote:
> Hello,
>
> there seems to be a bug, at least for me, in kernel/param.c for arrays
> with .num == NULL. If .num == NULL, the function param_array_set() uses
> &.max for the call to param_array(), wich alters the .max value to the
> number of arguments. The result is, you can't set more array arguments as
> the last time you set the parameter.
Yes. But this ignores the larger problem, in that the printing routines
need *some* way of telling how many to print. We could add a new
element for this case, at the price of enlarging the structure a little
for every array parameter. I think you'll find that with your patch,
the code does this:
$ insmod example.ko array=1,2,3
$ cat /sys/module/example/parameters/array
1,2,3,0,0,0,0,0,0,0
Cheers,
Rusty.
--
A bad analogy is like a leaky screwdriver -- Richard Braakman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel/param.c: don't use .max when .num is NULL in param_array_set()
2005-03-29 6:05 ` Rusty Russell
@ 2005-03-29 10:07 ` Bert Wesarg
0 siblings, 0 replies; 3+ messages in thread
From: Bert Wesarg @ 2005-03-29 10:07 UTC (permalink / raw)
To: Rusty Russell; +Cc: lkml - Kernel Mailing List
On Tue, 29 Mar 2005, Rusty Russell wrote:
> On Sun, 2005-03-27 at 14:57 +0200, Bert Wesarg wrote:
> > Hello,
> >
> > there seems to be a bug, at least for me, in kernel/param.c for arrays
> > with .num == NULL. If .num == NULL, the function param_array_set() uses
> > &.max for the call to param_array(), wich alters the .max value to the
> > number of arguments. The result is, you can't set more array arguments as
> > the last time you set the parameter.
>
> Yes. But this ignores the larger problem, in that the printing routines
> need *some* way of telling how many to print. We could add a new
> element for this case, at the price of enlarging the structure a little
> for every array parameter. I think you'll find that with your patch,
> the code does this:
>
> $ insmod example.ko array=1,2,3
> $ cat /sys/module/example/parameters/array
> 1,2,3,0,0,0,0,0,0,0
Yes, but in this case you can/will past a num pointer to
module_param_array(), when it is important to know how many arguments are
specified.
greetings,
bert
>
> Cheers,
> Rusty.
> --
> A bad analogy is like a leaky screwdriver -- Richard Braakman
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-29 10:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-27 12:57 [PATCH] kernel/param.c: don't use .max when .num is NULL in param_array_set() Bert Wesarg
2005-03-29 6:05 ` Rusty Russell
2005-03-29 10:07 ` Bert Wesarg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®