From a276fe93a91a76747b9ca444998b979e21d21fe3 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 18:27:13 +0200 Subject: [PATCH] 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 --- tools/depmod.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.47.3