[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230309160201.5163-31-tzimmermann@suse.de>
Date: Thu, 9 Mar 2023 17:00:50 +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 030/101] fbdev/gxt4500: 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 constifying the option string.
v2:
* replace static memory with kstrdup()/kfree() (Geert)
Signed-off-by: Thomas Zimmermann <tzimmermann@...e.de>
---
drivers/video/fbdev/gxt4500.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/gxt4500.c b/drivers/video/fbdev/gxt4500.c
index 5f42d3d9d6ce..65cb44c281c1 100644
--- a/drivers/video/fbdev/gxt4500.c
+++ b/drivers/video/fbdev/gxt4500.c
@@ -158,6 +158,7 @@ struct gxt4500_par {
};
/* mode requested by user */
+static char *mode_option_buf;
static char *mode_option;
/* default mode: 1280x1024 @ 60 Hz, 8 bpp */
@@ -779,12 +780,21 @@ static struct pci_driver gxt4500_driver = {
static int gxt4500_init(void)
{
+#ifndef MODULE
+ char *options;
+#endif
+
if (fb_modesetting_disabled("gxt4500"))
return -ENODEV;
#ifndef MODULE
- if (fb_get_options("gxt4500", &mode_option))
+ if (fb_get_options("gxt4500", &options))
return -ENODEV;
+
+ if (options && *options) {
+ mode_option_buf = kstrdup(options, GFP_KERNEL); // ignore errors
+ mode_option = mode_option_buf;
+ }
#endif
return pci_register_driver(&gxt4500_driver);
@@ -794,6 +804,7 @@ module_init(gxt4500_init);
static void __exit gxt4500_exit(void)
{
pci_unregister_driver(&gxt4500_driver);
+ kfree(mode_option_buf);
}
module_exit(gxt4500_exit);
--
2.39.2
Powered by blists - more mailing lists