lkml.org 
[lkml]   [2023]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 099/101] staging/sm750fb: Duplicate video-mode option string
Date
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@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
\
 
 \ /
  Last update: 2023-03-27 00:52    [W:0.358 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site