From: wgpierce17@gmail.com
To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu
Cc: alex@ghiti.fr, linux-riscv@lists.infradead.org,
Will Pierce <wgpierce17@gmail.com>
Subject: [PATCH] riscv: Use kvmalloc_array on relocation_hashtable
Date: Tue, 1 Apr 2025 22:34:08 -0700 [thread overview]
Message-ID: <20250402053408.14052-1-wgpierce17@gmail.com> (raw)
In-Reply-To: <d9714824-810c-4dd8-aff4-d1431235702b@gmail.com>
From: Will Pierce <wgpierce17@gmail.com>
The number of relocations may be a huge value that is unallocatable
by kmalloc. Use kvmalloc instead so that it does not fail.
Signed-off-by: Will Pierce <wgpierce17@gmail.com>
---
arch/riscv/kernel/module.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 47d0ebeec93c..bae3db50647c 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -648,7 +648,7 @@ process_accumulated_relocations(struct module *me,
kfree(bucket_iter);
}
- kfree(*relocation_hashtable);
+ kvfree(*relocation_hashtable);
}
static int add_relocation_to_accumulate(struct module *me, int type,
@@ -752,7 +752,8 @@ initialize_relocation_hashtable(unsigned int num_relocations,
hashtable_size <<= should_double_size;
- *relocation_hashtable = kmalloc_array(hashtable_size,
+ /* Number of relocations may be large, so kvmalloc it */
+ *relocation_hashtable = kvmalloc_array(hashtable_size,
sizeof(**relocation_hashtable),
GFP_KERNEL);
if (!*relocation_hashtable)
--
2.49.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-04-02 5:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-30 20:12 [BUG] Module load relocation hashtable size can become huge and unallocatable William Pierce
2025-04-01 3:10 ` William Pierce
2025-04-01 7:55 ` Clément Léger
2025-04-01 21:00 ` William Pierce
2025-04-02 5:34 ` wgpierce17 [this message]
2025-04-02 6:56 ` [PATCH] riscv: Use kvmalloc_array on relocation_hashtable Alexandre Ghiti
2025-04-02 8:12 ` William Pierce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250402053408.14052-1-wgpierce17@gmail.com \
--to=wgpierce17@gmail.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox