[PATCH v2 099/101] staging/sm750fb: Duplicate video-mode option string
Thomas Zimmermann
tzimmermann at suse.de
Thu Mar 9 16:01:59 UTC 2023
Assume that the driver does not own the option string or its substrings
and hence duplicate the option stringis for the video mode. Allocate each
copy's memory with kstrdup() and free it in the module's exit function.
Done in preparation of switching the driver to struct option_iter and
constifying the option string.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
drivers/staging/sm750fb/sm750.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index fa8ae20bb688..f0dbf7535ca8 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -911,11 +911,11 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
g_hwcursor = 0;
} else {
if (!g_fbmode[0]) {
- g_fbmode[0] = opt;
+ g_fbmode[0] = kstrdup(opt, GFP_KERNEL); // ignore errors
dev_info(&sm750_dev->pdev->dev,
"find fbmode0 : %s\n", g_fbmode[0]);
} else if (!g_fbmode[1]) {
- g_fbmode[1] = opt;
+ g_fbmode[1] = kstrdup(opt, GFP_KERNEL); // ignore errors
dev_info(&sm750_dev->pdev->dev,
"find fbmode1 : %s\n", g_fbmode[1]);
} else {
@@ -1182,7 +1182,14 @@ module_init(lynxfb_init);
static void __exit lynxfb_exit(void)
{
+ size_t i = ARRAY_SIZE(g_fbmode);
+
pci_unregister_driver(&lynxfb_driver);
+
+ while (i) {
+ --i;
+ kfree(g_fbmode[i]);
+ }
kfree(g_settings);
}
module_exit(lynxfb_exit);
--
2.39.2
More information about the dri-devel
mailing list