]> err.no Git - linux-2.6/commitdiff
kbuild: fix segmentation fault in modpost
authorSam Ravnborg <sam@ravnborg.org>
Mon, 26 Feb 2007 18:46:52 +0000 (19:46 +0100)
committerSam Ravnborg <sam@ravnborg.org>
Wed, 2 May 2007 18:58:07 +0000 (20:58 +0200)
If modpost was called manually with filenames without '/'
then modpost would segfault.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
scripts/mod/modpost.c

index e1f2b31cf34b7d1fb68007a8fac151977b6bd528..281abb77e03329bf83df6b02fb3896c2643d83f7 100644 (file)
@@ -1345,6 +1345,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;
 
@@ -1352,8 +1353,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");