* [PATCH] param, charp: Cache val length
@ 2013-02-18 9:12 Borislav Petkov
2013-02-18 11:24 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2013-02-18 9:12 UTC (permalink / raw)
To: LKML; +Cc: Borislav Petkov, Rusty Russell, Greg Kroah-Hartman
From: Borislav Petkov <bp@suse.de>
... instead of doing strlen twice.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/params.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/params.c b/kernel/params.c
index ed35345be536..d9401d66f5be 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -262,7 +262,10 @@ STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, strict_strtoul);
int param_set_charp(const char *val, const struct kernel_param *kp)
{
- if (strlen(val) > 1024) {
+ unsigned len;
+
+ len = strlen(val);
+ if (len > 1024) {
pr_err("%s: string parameter too long\n", kp->name);
return -ENOSPC;
}
@@ -272,7 +275,7 @@ int param_set_charp(const char *val, const struct kernel_param *kp)
/* This is a hack. We can't kmalloc in early boot, and we
* don't need to; this mangled commandline is preserved. */
if (slab_is_available()) {
- *(char **)kp->arg = kmalloc_parameter(strlen(val)+1);
+ *(char **)kp->arg = kmalloc_parameter(len + 1);
if (!*(char **)kp->arg)
return -ENOMEM;
strcpy(*(char **)kp->arg, val);
--
1.8.1.3.535.ga923c31
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] param, charp: Cache val length
2013-02-18 9:12 [PATCH] param, charp: Cache val length Borislav Petkov
@ 2013-02-18 11:24 ` Rusty Russell
2013-02-19 11:59 ` Borislav Petkov
0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2013-02-18 11:24 UTC (permalink / raw)
To: Borislav Petkov, LKML; +Cc: Borislav Petkov, Greg Kroah-Hartman
Borislav Petkov <bp@alien8.de> writes:
> From: Borislav Petkov <bp@suse.de>
>
> ... instead of doing strlen twice.
I'm delighted with your enthusiasm for making trivial changes, but I
have trouble sharing in it.
In this case, it's so marginal that I'll leave the status quo.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] param, charp: Cache val length
2013-02-18 11:24 ` Rusty Russell
@ 2013-02-19 11:59 ` Borislav Petkov
0 siblings, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2013-02-19 11:59 UTC (permalink / raw)
To: Rusty Russell; +Cc: LKML, Borislav Petkov, Greg Kroah-Hartman
On Mon, Feb 18, 2013 at 09:54:22PM +1030, Rusty Russell wrote:
> I'm delighted with your enthusiasm for making trivial changes,
Who says I'm enthusiastic about it?
> but I have trouble sharing in it.
I just assumed that noodling for a second time over a string of possible
length of 1024 chars (I know, I know, we will never have params of that
length, yadda yadda...) should be avoided.
Nevermind.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-19 11:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-18 9:12 [PATCH] param, charp: Cache val length Borislav Petkov
2013-02-18 11:24 ` Rusty Russell
2013-02-19 11:59 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox