From: Petr Pavlu <petr.pavlu@suse.com>
To: Chris Zankel <chris@zankel.net>,
Max Filippov <jcmvbkbc@gmail.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>
Cc: Aaron Tomlin <atomlin@atomlin.com>,
Matthew Wood <thepacketgeek@gmail.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] xtensa/simdisk: Avoid referring to module::args
Date: Thu, 4 Jun 2026 13:04:45 +0200 [thread overview]
Message-ID: <20260604110455.1608038-2-petr.pavlu@suse.com> (raw)
In-Reply-To: <20260604110455.1608038-1-petr.pavlu@suse.com>
When simdisk support is built as a loadable module,
simdisk_param_set_filename() receives a pointer into module::args and
stores each filename pointer as is.
In preparation for removing module::args, update the simdisk.filename
parameter code to copy the provided string. This is somewhat complicated by
the fact that simdisk support can also be built-in, in which case the
parameters are parsed during early boot before slab is available. In that
case, the command line itself is preserved for the lifetime of the kernel,
so continue storing the incoming pointer directly.
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
---
arch/xtensa/platforms/iss/simdisk.c | 38 +++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c
index 7c7a2aa749f8..a2ddb49c269d 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -41,7 +41,7 @@ module_param(simdisk_count, int, S_IRUGO);
MODULE_PARM_DESC(simdisk_count, "Number of simdisk units.");
static int n_files;
-static const char *filename[MAX_SIMDISK_COUNT] = {
+static char *filename[MAX_SIMDISK_COUNT] = {
#ifdef CONFIG_SIMDISK0_FILENAME
CONFIG_SIMDISK0_FILENAME,
#ifdef CONFIG_SIMDISK1_FILENAME
@@ -50,20 +50,48 @@ static const char *filename[MAX_SIMDISK_COUNT] = {
#endif
};
+/*
+ * The simdisk code can be built either into the kernel or as a loadable module.
+ * When built-in, CONFIG_SIMDISK{0,1}_FILENAME can be used to specify the
+ * initial simdisk filenames and additional filenames can be provided on the
+ * kernel command line. These arguments are parsed during early boot when slab
+ * is not yet available, but the command line itself is preserved for the
+ * lifetime of the kernel, so the incoming pointer is stored directly.
+ * When built as a loadable module, each value is copied with kstrdup() and all
+ * allocated memory is freed in simdisk_param_free_filename() when the module is
+ * unloaded.
+ */
static int simdisk_param_set_filename(const char *val,
const struct kernel_param *kp)
{
- if (n_files < ARRAY_SIZE(filename))
- filename[n_files++] = val;
- else
+ char *str;
+
+ if (n_files >= ARRAY_SIZE(filename))
return -EINVAL;
+
+#ifdef MODULE
+ str = kstrdup(val, GFP_KERNEL);
+ if (!str)
+ return -ENOMEM;
+#else
+ str = (char *)val;
+#endif
+
+ filename[n_files++] = str;
return 0;
}
+static void simdisk_param_free_filename(void *arg)
+{
+ for (int i = 0; i < n_files; i++)
+ kfree(filename[i]);
+}
+
static const struct kernel_param_ops simdisk_param_ops_filename = {
.set = simdisk_param_set_filename,
+ .free = simdisk_param_free_filename,
};
-module_param_cb(filename, &simdisk_param_ops_filename, &n_files, 0);
+module_param_cb(filename, &simdisk_param_ops_filename, NULL, 0);
MODULE_PARM_DESC(filename, "Backing storage filename.");
static int simdisk_major = SIMDISK_MAJOR;
--
2.54.0
next prev parent reply other threads:[~2026-06-04 11:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 11:04 [PATCH 0/2] module: Remove unnecessary module::args Petr Pavlu
2026-06-04 11:04 ` Petr Pavlu [this message]
2026-06-07 20:44 ` [PATCH 1/2] xtensa/simdisk: Avoid referring to module::args Max Filippov
2026-06-04 11:04 ` [PATCH 2/2] module: Remove unnecessary module::args Petr Pavlu
2026-06-04 13:25 ` Aaron Tomlin
2026-07-09 9:02 ` [PATCH 0/2] " Petr Pavlu
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=20260604110455.1608038-2-petr.pavlu@suse.com \
--to=petr.pavlu@suse.com \
--cc=atomlin@atomlin.com \
--cc=chris@zankel.net \
--cc=da.gomez@kernel.org \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.com \
--cc=thepacketgeek@gmail.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
all inboxes | Powered by JetHome®