[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230309160201.5163-83-tzimmermann@suse.de>
Date: Thu, 9 Mar 2023 17:01:42 +0100
From: Thomas Zimmermann <tzimmermann@...e.de>
To: deller@....de, geert+renesas@...der.be, timur@...nel.org,
rdunlap@...radead.org, paulus@...ba.org, benh@...nel.crashing.org,
linux@...linux.org.uk, pjones@...hat.com, adaplas@...il.com,
s.hauer@...gutronix.de, shawnguo@...nel.org, mbroemme@...mpq.org,
thomas@...ischhofer.net, James.Bottomley@...senPartnership.com,
sudipm.mukherjee@...il.com, teddy.wang@...iconmotion.com,
corbet@....net
Cc: linux-fbdev@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
Thomas Zimmermann <tzimmermann@...e.de>
Subject: [PATCH v2 082/101] fbdev/tgafb: Duplicate video-mode option string
Assume that the driver does not own the option string or its substrings
and hence duplicate the option string for the video mode. Allocate the
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.
v2:
* replace static memory with kstrdup()/kfree() (Geert)
Signed-off-by: Thomas Zimmermann <tzimmermann@...e.de>
---
drivers/video/fbdev/tgafb.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c
index 14d37c49633c..cf00b8a91bfb 100644
--- a/drivers/video/fbdev/tgafb.c
+++ b/drivers/video/fbdev/tgafb.c
@@ -59,6 +59,7 @@ static int tgafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info
static int tgafb_register(struct device *dev);
static void tgafb_unregister(struct device *dev);
+static const char *mode_option_buf;
static const char *mode_option;
static const char *mode_option_pci = "640x480@60";
static const char *mode_option_tc = "1280x1024@72";
@@ -1568,6 +1569,7 @@ static void tgafb_exit(void)
{
tc_unregister_driver(&tgafb_tc_driver);
pci_unregister_driver(&tgafb_pci_driver);
+ kfree(mode_option_buf);
}
#ifndef MODULE
@@ -1579,9 +1581,11 @@ static int tgafb_setup(char *arg)
while ((this_opt = strsep(&arg, ","))) {
if (!*this_opt)
continue;
- if (!strncmp(this_opt, "mode:", 5))
- mode_option = this_opt+5;
- else
+ if (!strncmp(this_opt, "mode:", 5)) {
+ kfree(mode_option_buf);
+ mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors
+ mode_option = mode_option_buf;
+ } else
printk(KERN_ERR
"tgafb: unknown parameter %s\n",
this_opt);
--
2.39.2
Powered by blists - more mailing lists