From: Borislav Petkov <bp@alien8.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Borislav Petkov <bp@suse.de>,
Rusty Russell <rusty@rustcorp.com.au>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] param, charp: Cache val length
Date: Mon, 18 Feb 2013 10:12:30 +0100 [thread overview]
Message-ID: <1361178750-17915-1-git-send-email-bp@alien8.de> (raw)
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
next reply other threads:[~2013-02-18 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 9:12 Borislav Petkov [this message]
2013-02-18 11:24 ` Rusty Russell
2013-02-19 11:59 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361178750-17915-1-git-send-email-bp@alien8.de \
--to=bp@alien8.de \
--cc=bp@suse.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome