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;
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@suse.de> --- drivers/video/fbdev/imxfb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)