From: Andrey Panin <pazke@donpac.ru>
To: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] 2.6.13-rc5-mm1, make dmi_string() behave like strdup()
Date: Wed, 10 Aug 2005 14:32:51 +0400 [thread overview]
Message-ID: <11236699713656@donpac.ru> (raw)
In-Reply-To: <11236699682765@donpac.ru>
This patch changes dmi_string() function to allocate string copy by itself,
to avoid code duplication in the next patch.
Signed-off-by: Andrey Panin <pazke@donpac.ru>
arch/i386/kernel/dmi_scan.c | 39 +++++++++++++++++++++++----------------
1 files changed, 23 insertions(+), 16 deletions(-)
diff -urdpNX /usr/share/dontdiff linux-2.6.13-rc5-mm1.vanilla/arch/i386/kernel/dmi_scan.c linux-2.6.13-rc5-mm1/arch/i386/kernel/dmi_scan.c
--- linux-2.6.13-rc5-mm1.vanilla/arch/i386/kernel/dmi_scan.c 2005-06-14 23:31:39.000000000 +0400
+++ linux-2.6.13-rc5-mm1/arch/i386/kernel/dmi_scan.c 2005-06-14 23:31:51.000000000 +0400
@@ -16,15 +16,25 @@ struct dmi_header {
static char * __init dmi_string(struct dmi_header *dm, u8 s)
{
u8 *bp = ((u8 *) dm) + dm->length;
+ char *str = "";
- if (!s)
- return "";
- s--;
- while (s > 0 && *bp) {
- bp += strlen(bp) + 1;
+ if (s) {
s--;
- }
- return bp;
+ while (s > 0 && *bp) {
+ bp += strlen(bp) + 1;
+ s--;
+ }
+
+ if (*bp != 0) {
+ str = alloc_bootmem(strlen(bp) + 1);
+ if (str != NULL)
+ strcpy(str, bp);
+ else
+ printk(KERN_ERR "dmi_string: out of memory.\n");
+ }
+ }
+
+ return str;
}
/*
@@ -84,19 +94,16 @@ static char *dmi_ident[DMI_STRING_MAX];
*/
static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
{
- char *d = (char*)dm;
- char *p = dmi_string(dm, d[string]);
+ char *p, *d = (char*) dm;
- if (p == NULL || *p == 0)
- return;
if (dmi_ident[slot])
return;
- dmi_ident[slot] = alloc_bootmem(strlen(p) + 1);
- if(dmi_ident[slot])
- strcpy(dmi_ident[slot], p);
- else
- printk(KERN_ERR "dmi_save_ident: out of memory.\n");
+ p = dmi_string(dm, d[string]);
+ if (p == NULL)
+ return;
+
+ dmi_ident[slot] = p;
}
/*
next prev parent reply other threads:[~2005-08-10 10:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-10 10:32 [PATCH 0/5] 2.6.13-rc5-mm1, remove uneeded function Andrey Panin
2005-08-10 10:32 ` [PATCH 1/5] 2.6.13-rc5-mm1, remove old debugging code Andrey Panin
2005-08-10 10:32 ` Andrey Panin [this message]
2005-08-10 10:32 ` [PATCH 3/5] 2.6.13-rc5-mm1, add onboard devices discovery Andrey Panin
2005-08-10 10:32 ` [PATCH 4/5] 2.6.13-rc5-mm1, IPMI, use dmi_find_device() Andrey Panin
2005-08-10 10:32 ` [PATCH 5/5] 2.6.13-rc5-mm1, driver for IBM Automatic Server Restart watchdog Andrey Panin
2005-08-17 20:14 ` Andrew Morton
2005-08-18 4:49 ` Andrey Panin
2005-08-10 14:12 ` [PATCH 4/5] 2.6.13-rc5-mm1, IPMI, use dmi_find_device() Corey Minyard
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=11236699713656@donpac.ru \
--to=pazke@donpac.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.