[PATCH v2 011/101] fbdev/aty: 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/aty/aty128fb.c    | 8 +++++++-
 drivers/video/fbdev/aty/atyfb_base.c  | 9 +++++++--
 drivers/video/fbdev/aty/radeon_base.c | 9 +++++++--
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
index 36a9ac05a340..0e725a6eb40b 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -383,6 +383,7 @@ static const struct fb_fix_screeninfo aty128fb_fix = {
 	.accel		= FB_ACCEL_ATI_RAGE128,
 };
 
+static char *mode_option_buf;
 static char *mode_option = NULL;
 
 #ifdef CONFIG_PPC_PMAC
@@ -1723,7 +1724,11 @@ static int aty128fb_setup(char *options)
 			continue;
 		}
 #endif /* CONFIG_PPC_PMAC */
-		mode_option = this_opt;
+		{
+			kfree(mode_option_buf);
+			mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors
+			mode_option = mode_option_buf;
+		}
 	}
 	return 0;
 }
@@ -2518,6 +2523,7 @@ static int aty128fb_init(void)
 static void __exit aty128fb_exit(void)
 {
 	pci_unregister_driver(&aty128fb_driver);
+	kfree(mode_option_buf);
 }
 
 module_init(aty128fb_init);
diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
index b02e4e645035..d83b3dae795b 100644
--- a/drivers/video/fbdev/aty/atyfb_base.c
+++ b/drivers/video/fbdev/aty/atyfb_base.c
@@ -326,6 +326,7 @@ static int pll;
 static int mclk;
 static int xclk;
 static int comp_sync = -1;
+static char *mode_buf;
 static char *mode;
 static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT);
 
@@ -3896,8 +3897,11 @@ static int __init atyfb_setup(char *options)
 			}
 		}
 #endif
-		else
-			mode = this_opt;
+		else {
+			kfree(mode_buf);
+			mode_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors
+			mode = mode_buf;
+		}
 	}
 	return 0;
 }
@@ -3995,6 +3999,7 @@ static void __exit atyfb_exit(void)
 #ifdef CONFIG_PCI
 	pci_unregister_driver(&atyfb_driver);
 #endif
+	kfree(mode_buf);
 }
 
 module_init(atyfb_init);
diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
index 657064227de8..dc2657ae96f2 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -257,6 +257,7 @@ static reg_val common_regs[] = {
  * globals
  */
 
+static char *mode_option_buf;
 static char *mode_option;
 static char *monitor_layout;
 static bool noaccel = 0;
@@ -2596,8 +2597,11 @@ static int __init radeonfb_setup (char *options)
 		} else if (!strncmp(this_opt, "ignore_devlist", 14)) {
 			ignore_devlist = 1;
 #endif
-		} else
-			mode_option = this_opt;
+		} else {
+			kfree(mode_option_buf);
+			mode_option_buf = kstrdup(this_opt, GFP_KERNEL); // ignore errors
+			mode_option = mode_option_buf;
+		}
 	}
 	return 0;
 }
@@ -2624,6 +2628,7 @@ static int __init radeonfb_init (void)
 static void __exit radeonfb_exit (void)
 {
 	pci_unregister_driver (&radeonfb_driver);
+	kfree(mode_option_buf);
 }
 
 module_init(radeonfb_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