kbuild: fix segmentation fault in modpost
From: Sam Ravnborg
Date: Mon Feb 26 2007 - 13:46:52 EST
If modpost was called manually with filenames without '/'
then modpost would segfault.
Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
---
scripts/mod/modpost.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2b3b066..15d69c4 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1344,6 +1344,7 @@ static void add_depends(struct buffer *b, struct module *mod,
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
+ const char *p;
if (!s->module)
continue;
@@ -1351,8 +1352,11 @@ static void add_depends(struct buffer *b, struct module *mod,
continue;
s->module->seen = 1;
- buf_printf(b, "%s%s", first ? "" : ",",
- strrchr(s->module->name, '/') + 1);
+ if ((p = strrchr(s->module->name, '/')) != NULL)
+ p++;
+ else
+ p = s->module->name;
+ buf_printf(b, "%s%s", first ? "" : ",", p);
first = 0;
}
buf_printf(b, "\";\n");
--
1.4.4.2