From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 16:27:13 +0000 (+0200) Subject: depmod: Actually use scratch buffer memory X-Git-Tag: v34~271 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a276fe93a91a76747b9ca444998b979e21d21fe3;p=thirdparty%2Fkmod.git depmod: Actually use scratch buffer memory Accessing the backing "alias" char buffer directly works only as long as all symbols are smaller than 1024, because otherwise the scratch buffer allocates memory and the addresses do not match anymore. Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/166 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 4718f4d1..3117b78e 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2330,6 +2330,7 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out) int duplicate; const struct symbol *sym = v; size_t len; + char *s; if (sym->owner == NULL) continue; @@ -2340,12 +2341,12 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out) ret = -ENOMEM; goto err_scratchbuf; } - memcpy(scratchbuf_str(&salias) + baselen, sym->name, len + 1); - duplicate = - index_insert(idx, alias, sym->owner->modname, sym->owner->idx); + s = scratchbuf_str(&salias); + memcpy(s + baselen, sym->name, len + 1); + duplicate = index_insert(idx, s, sym->owner->modname, sym->owner->idx); if (duplicate && depmod->cfg->warn_dups) - WRN("duplicate module syms:\n%s %s\n", alias, sym->owner->modname); + WRN("duplicate module syms:\n%s %s\n", s, sym->owner->modname); } index_write(idx, out);