Skip to contentSkip to conversation

modpost: add NOFAIL to strdup call

PATCH In review Denis Efremov 2 participants 2 messages Oct 15, 2019 – Oct 17, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modpost: add NOFAIL to strdup call

Add NOFAIL check for the strdup call, since the function allocates memory and can return NULL. All strdup calls in modpost are checked with NOFAIL.

---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index 936d3ad23c83..8e8975065cbc 100644
@@ -384,7 +384,7 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
 		}
 	}
 	free(s->namespace);
-	s->namespace = namespace ? strdup(namespace) : NULL;
+	s->namespace = namespace ? NOFAIL(strdup(namespace)) : NULL;
 	s->preloaded = 0;
 	s->vmlinux   = is_vmlinux(mod->name);
 	s->kernel    = 0;
Signature · 1 line
2.21.0
#1 lore raw
Quoted 15 lines · Denis Efremov

Add NOFAIL check for the strdup call, since the function allocates memory and can return NULL. All strdup calls in modpost are checked with NOFAIL.

---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +0 -0
index 936d3ad23c83..8e8975065cbc 100644

scripts/mod/modpost.c static struct symbol *sym_add_exported(const char *name, const char *namespace, · line 387

Quoted 5 lines
scripts/mod/modpost.c +1 -1
@@ -384,7 +384,7 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
                }
        }
        free(s->namespace);
-       s->namespace = namespace ? strdup(namespace) : NULL;
+       s->namespace = namespace ? NOFAIL(strdup(namespace)) : NULL;

This is correct, but I will put it off
because otherwise if would cause a conflict against this patch:

https://lore.kernel.org/patchwork/patch/1138151/

That patch is adding NOFAIL().

Quoted 6 lines
scripts/mod/modpost.c +0 -1
        s->preloaded = 0;
        s->vmlinux   = is_vmlinux(mod->name);
        s->kernel    = 0;
--

2.21.0

Signature · 2 lines
Best Regards
Masahiro Yamada