[PATCH v2 026/101] fbdev/geode: Duplicate video-mode option string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Assume that the drivers do 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 each 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@xxxxxxx>
---
 drivers/video/fbdev/geode/gxfb_core.c | 6 +++++-
 drivers/video/fbdev/geode/lxfb_core.c | 9 +++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c
index 8e05e76de075..491de0ac5876 100644
--- a/drivers/video/fbdev/geode/gxfb_core.c
+++ b/drivers/video/fbdev/geode/gxfb_core.c
@@ -33,6 +33,7 @@
 
 #include "gxfb.h"
 
+static char *mode_option_buf;
 static char *mode_option;
 static int vram;
 static int vt_switch;
@@ -500,7 +501,9 @@ static int __init gxfb_setup(char *options)
 		if (!*opt)
 			continue;
 
-		mode_option = opt;
+		kfree(mode_option_buf);
+		mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors
+		mode_option = mode_option_buf;
 	}
 
 	return 0;
@@ -528,6 +531,7 @@ static int __init gxfb_init(void)
 static void __exit gxfb_cleanup(void)
 {
 	pci_unregister_driver(&gxfb_driver);
+	kfree(mode_option_buf);
 }
 
 module_init(gxfb_init);
diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c
index 8130e9eee2b4..6863ee858d8d 100644
--- a/drivers/video/fbdev/geode/lxfb_core.c
+++ b/drivers/video/fbdev/geode/lxfb_core.c
@@ -24,6 +24,7 @@
 
 #include "lxfb.h"
 
+static char *mode_option_buf;
 static char *mode_option;
 static int noclear, nopanel, nocrt;
 static int vram;
@@ -635,8 +636,11 @@ static int __init lxfb_setup(char *options)
 			nopanel = 1;
 		else if (!strcmp(opt, "nocrt"))
 			nocrt = 1;
-		else
-			mode_option = opt;
+		else {
+			kfree(mode_option_buf);
+			mode_option_buf = kstrdup(opt, GFP_KERNEL); // ignore errors
+			mode_option = mode_option_buf;
+		}
 	}
 
 	return 0;
@@ -663,6 +667,7 @@ static int __init lxfb_init(void)
 static void __exit lxfb_cleanup(void)
 {
 	pci_unregister_driver(&lxfb_driver);
+	kfree(mode_option_buf);
 }
 
 module_init(lxfb_init);
-- 
2.39.2




[Index of Archives]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Tourism]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux