[PATCH 39/99] fbdev/imxfb: Duplicate video-mode option string

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

 



Assume that the driver does not own the option string or its substrings
and hence duplicate the option string for the video mode. The driver only
parses the option string once as part of module initialization, so use
a static buffer to store the duplicated mode option. Linux automatically
frees the memory upon releasing the module.

Done in preparation of switching the driver to struct option_iter and
constifying the option string.

Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
---
 drivers/video/fbdev/imxfb.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
index 51fde1b2a793..34cd4d4fd137 100644
--- a/drivers/video/fbdev/imxfb.c
+++ b/drivers/video/fbdev/imxfb.c
@@ -854,10 +854,18 @@ static int imxfb_setup(void)
 		return 0;
 
 	while ((opt = strsep(&options, ",")) != NULL) {
+		static char mode_option_buf[256];
+		int ret;
+
 		if (!*opt)
 			continue;
-		else
-			fb_mode = opt;
+
+		ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", opt);
+		if (WARN(ret < 0, "imxfb: ignoring invalid option, ret=%d\n", ret))
+			continue;
+		if (WARN(ret >= sizeof(mode_option_buf), "imxfb: option too long\n"))
+			continue;
+		fb_mode = mode_option_buf;
 	}
 
 	return 0;
-- 
2.39.2




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

  Powered by Linux