All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] fbcon: use kstrtouint instead of deprecated function simple_strtoul.
@ 2012-07-24  1:00 ` Paul Cercueil
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |  102 ++++++++++++++++++++++++++++-------------
 1 file changed, 69 insertions(+), 33 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 2e471c2..a0b1818 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -435,7 +435,7 @@ static void fbcon_del_cursor_timer(struct fb_info *info)
 static int __init fb_console_setup(char *this_opt)
 {
 	char *options;
-	int i, j;
+	int i, j, ret;
 
 	if (!this_opt || !*this_opt)
 		return 1;
@@ -445,18 +445,29 @@ static int __init fb_console_setup(char *this_opt)
 			strcpy(fontname, options + 5);
 		
 		if (!strncmp(options, "scrollback:", 11)) {
+			char *k;
 			options += 11;
-			if (*options) {
-				fbcon_softback_size = simple_strtoul(options, &options, 0);
-				if (*options == 'k' || *options == 'K') {
-					fbcon_softback_size *= 1024;
-					options++;
-				}
-				if (*options != ',')
-					return 1;
-				options++;
-			} else
-				return 1;
+			k = options;
+
+			while (*k != '\0' && *k != 'k' && *k != 'K')
+				k++;
+
+			/* Clear the 'k' or 'K' suffix to
+			 * prevent errors with kstrtouint */
+			if (*k != '\0')
+				*k++ = '\0';
+			else
+				k = NULL;
+
+			ret = kstrtouint(options, 0, (unsigned int *)
+						&fbcon_softback_size);
+
+			if (!ret && k)
+				fbcon_softback_size *= 1024;
+
+			/* (k && *k): Check for garbage after the suffix */
+			if (ret || (k && *k))
+				pr_warn("fbcon: scrollback: incorrect value.\n");
 		}
 		
 		if (!strncmp(options, "map:", 4)) {
@@ -476,22 +487,44 @@ static int __init fb_console_setup(char *this_opt)
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
+			char *dash;
 			options += 3;
-			if (*options)
-				first_fb_vc = simple_strtoul(options, &options, 10) - 1;
-			if (first_fb_vc < 0)
-				first_fb_vc = 0;
-			if (*options++ == '-')
-				last_fb_vc = simple_strtoul(options, &options, 10) - 1;
-			fbcon_is_default = 0; 
-		}	
+
+			dash = strchr(options, '-');
+			if (dash)
+				*dash++ = '\0';
+
+			ret = kstrtouint(options, 10,
+						(unsigned int *) &first_fb_vc);
+			if (!ret) {
+				if (--first_fb_vc < 0)
+					first_fb_vc = 0;
+
+				if (dash) {
+					ret = kstrtouint(dash, 10,
+								(unsigned int *)
+								&last_fb_vc);
+					if (!ret)
+						last_fb_vc--;
+				}
+			}
+
+			if (!ret)
+				fbcon_is_default = 0;
+			else
+				pr_warn("fbcon: vc: incorrect value.\n");
+		}
 
 		if (!strncmp(options, "rotate:", 7)) {
 			options += 7;
-			if (*options)
-				initial_rotation = simple_strtoul(options, &options, 0);
-			if (initial_rotation > 3)
-				initial_rotation = 0;
+			ret = kstrtouint(options, 0, (unsigned int *)
+						&initial_rotation);
+			if (!ret) {
+				if (initial_rotation > 3)
+					initial_rotation = 0;
+			} else {
+				pr_warn("fbcon: rotate: incorrect value.\n");
+			}
 		}
 	}
 	return 1;
@@ -3312,8 +3345,8 @@ static ssize_t store_rotate(struct device *device,
 			    size_t count)
 {
 	struct fb_info *info;
-	int rotate, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int rotate;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3325,7 +3358,8 @@ static ssize_t store_rotate(struct device *device,
 		goto err;
 
 	info = registered_fb[idx];
-	rotate = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &rotate))
+		goto err;
 	fbcon_rotate(info, rotate);
 err:
 	console_unlock();
@@ -3337,8 +3371,8 @@ static ssize_t store_rotate_all(struct device *device,
 				size_t count)
 {
 	struct fb_info *info;
-	int rotate, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int rotate;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3350,7 +3384,8 @@ static ssize_t store_rotate_all(struct device *device,
 		goto err;
 
 	info = registered_fb[idx];
-	rotate = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &rotate))
+		goto err;
 	fbcon_rotate_all(info, rotate);
 err:
 	console_unlock();
@@ -3412,8 +3447,8 @@ static ssize_t store_cursor_blink(struct device *device,
 				  const char *buf, size_t count)
 {
 	struct fb_info *info;
-	int blink, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int blink;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3429,7 +3464,8 @@ static ssize_t store_cursor_blink(struct device *device,
 	if (!info->fbcon_par)
 		goto err;
 
-	blink = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &blink))
+		goto err;
 
 	if (blink) {
 		fbcon_cursor_noblink = 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 1/4] fbcon: use kstrtouint instead of deprecated function simple_strtoul.
@ 2012-07-24  1:00 ` Paul Cercueil
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |  102 ++++++++++++++++++++++++++++-------------
 1 file changed, 69 insertions(+), 33 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 2e471c2..a0b1818 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -435,7 +435,7 @@ static void fbcon_del_cursor_timer(struct fb_info *info)
 static int __init fb_console_setup(char *this_opt)
 {
 	char *options;
-	int i, j;
+	int i, j, ret;
 
 	if (!this_opt || !*this_opt)
 		return 1;
@@ -445,18 +445,29 @@ static int __init fb_console_setup(char *this_opt)
 			strcpy(fontname, options + 5);
 		
 		if (!strncmp(options, "scrollback:", 11)) {
+			char *k;
 			options += 11;
-			if (*options) {
-				fbcon_softback_size = simple_strtoul(options, &options, 0);
-				if (*options = 'k' || *options = 'K') {
-					fbcon_softback_size *= 1024;
-					options++;
-				}
-				if (*options != ',')
-					return 1;
-				options++;
-			} else
-				return 1;
+			k = options;
+
+			while (*k != '\0' && *k != 'k' && *k != 'K')
+				k++;
+
+			/* Clear the 'k' or 'K' suffix to
+			 * prevent errors with kstrtouint */
+			if (*k != '\0')
+				*k++ = '\0';
+			else
+				k = NULL;
+
+			ret = kstrtouint(options, 0, (unsigned int *)
+						&fbcon_softback_size);
+
+			if (!ret && k)
+				fbcon_softback_size *= 1024;
+
+			/* (k && *k): Check for garbage after the suffix */
+			if (ret || (k && *k))
+				pr_warn("fbcon: scrollback: incorrect value.\n");
 		}
 		
 		if (!strncmp(options, "map:", 4)) {
@@ -476,22 +487,44 @@ static int __init fb_console_setup(char *this_opt)
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
+			char *dash;
 			options += 3;
-			if (*options)
-				first_fb_vc = simple_strtoul(options, &options, 10) - 1;
-			if (first_fb_vc < 0)
-				first_fb_vc = 0;
-			if (*options++ = '-')
-				last_fb_vc = simple_strtoul(options, &options, 10) - 1;
-			fbcon_is_default = 0; 
-		}	
+
+			dash = strchr(options, '-');
+			if (dash)
+				*dash++ = '\0';
+
+			ret = kstrtouint(options, 10,
+						(unsigned int *) &first_fb_vc);
+			if (!ret) {
+				if (--first_fb_vc < 0)
+					first_fb_vc = 0;
+
+				if (dash) {
+					ret = kstrtouint(dash, 10,
+								(unsigned int *)
+								&last_fb_vc);
+					if (!ret)
+						last_fb_vc--;
+				}
+			}
+
+			if (!ret)
+				fbcon_is_default = 0;
+			else
+				pr_warn("fbcon: vc: incorrect value.\n");
+		}
 
 		if (!strncmp(options, "rotate:", 7)) {
 			options += 7;
-			if (*options)
-				initial_rotation = simple_strtoul(options, &options, 0);
-			if (initial_rotation > 3)
-				initial_rotation = 0;
+			ret = kstrtouint(options, 0, (unsigned int *)
+						&initial_rotation);
+			if (!ret) {
+				if (initial_rotation > 3)
+					initial_rotation = 0;
+			} else {
+				pr_warn("fbcon: rotate: incorrect value.\n");
+			}
 		}
 	}
 	return 1;
@@ -3312,8 +3345,8 @@ static ssize_t store_rotate(struct device *device,
 			    size_t count)
 {
 	struct fb_info *info;
-	int rotate, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int rotate;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3325,7 +3358,8 @@ static ssize_t store_rotate(struct device *device,
 		goto err;
 
 	info = registered_fb[idx];
-	rotate = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &rotate))
+		goto err;
 	fbcon_rotate(info, rotate);
 err:
 	console_unlock();
@@ -3337,8 +3371,8 @@ static ssize_t store_rotate_all(struct device *device,
 				size_t count)
 {
 	struct fb_info *info;
-	int rotate, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int rotate;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3350,7 +3384,8 @@ static ssize_t store_rotate_all(struct device *device,
 		goto err;
 
 	info = registered_fb[idx];
-	rotate = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &rotate))
+		goto err;
 	fbcon_rotate_all(info, rotate);
 err:
 	console_unlock();
@@ -3412,8 +3447,8 @@ static ssize_t store_cursor_blink(struct device *device,
 				  const char *buf, size_t count)
 {
 	struct fb_info *info;
-	int blink, idx;
-	char **last = NULL;
+	int idx;
+	unsigned int blink;
 
 	if (fbcon_has_exited)
 		return count;
@@ -3429,7 +3464,8 @@ static ssize_t store_cursor_blink(struct device *device,
 	if (!info->fbcon_par)
 		goto err;
 
-	blink = simple_strtoul(buf, last, 0);
+	if (kstrtouint(buf, 0, &blink))
+		goto err;
 
 	if (blink) {
 		fbcon_cursor_noblink = 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/4] fbcon: prevent possible buffer overflow.
  2012-07-24  1:00 ` Paul Cercueil
@ 2012-07-24  1:00   ` Paul Cercueil
  -1 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index a0b1818..3ffab97 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -442,7 +442,7 @@ static int __init fb_console_setup(char *this_opt)
 
 	while ((options = strsep(&this_opt, ",")) != NULL) {
 		if (!strncmp(options, "font:", 5))
-			strcpy(fontname, options + 5);
+			strlcpy(fontname, options + 5, sizeof(fontname));
 		
 		if (!strncmp(options, "scrollback:", 11)) {
 			char *k;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/4] fbcon: prevent possible buffer overflow.
@ 2012-07-24  1:00   ` Paul Cercueil
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index a0b1818..3ffab97 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -442,7 +442,7 @@ static int __init fb_console_setup(char *this_opt)
 
 	while ((options = strsep(&this_opt, ",")) != NULL) {
 		if (!strncmp(options, "font:", 5))
-			strcpy(fontname, options + 5);
+			strlcpy(fontname, options + 5, sizeof(fontname));
 		
 		if (!strncmp(options, "scrollback:", 11)) {
 			char *k;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/4] fbcon: continue parsing parameters after an error.
  2012-07-24  1:00 ` Paul Cercueil
@ 2012-07-24  1:00   ` Paul Cercueil
  -1 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 3ffab97..9b83b75 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -481,9 +481,9 @@ static int __init fb_console_setup(char *this_opt)
 				}
 
 				fbcon_map_override();
+			} else {
+				pr_warn("fbcon: map: incorrect value.\n");
 			}
-
-			return 1;
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/4] fbcon: continue parsing parameters after an error.
@ 2012-07-24  1:00   ` Paul Cercueil
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 3ffab97..9b83b75 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -481,9 +481,9 @@ static int __init fb_console_setup(char *this_opt)
 				}
 
 				fbcon_map_override();
+			} else {
+				pr_warn("fbcon: map: incorrect value.\n");
 			}
-
-			return 1;
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/4] fbcon: optimize parameters parsing loop.
  2012-07-24  1:00 ` Paul Cercueil
@ 2012-07-24  1:00   ` Paul Cercueil
  -1 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 9b83b75..1ecaf68 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -441,8 +441,10 @@ static int __init fb_console_setup(char *this_opt)
 		return 1;
 
 	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
 			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}
 		
 		if (!strncmp(options, "scrollback:", 11)) {
 			char *k;
@@ -468,6 +470,7 @@ static int __init fb_console_setup(char *this_opt)
 			/* (k && *k): Check for garbage after the suffix */
 			if (ret || (k && *k))
 				printk(KERN_WARNING "fbcon: scrollback: incorrect value.\n");
+			continue;
 		}
 		
 		if (!strncmp(options, "map:", 4)) {
@@ -484,6 +487,7 @@ static int __init fb_console_setup(char *this_opt)
 			} else {
 				printk(KERN_WARNING "fbcon: map: incorrect value.\n");
 			}
+			continue;
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
@@ -513,6 +517,7 @@ static int __init fb_console_setup(char *this_opt)
 				fbcon_is_default = 0;
 			else
 				printk(KERN_WARNING "fbcon: vc: incorrect value.\n");
+			continue;
 		}
 
 		if (!strncmp(options, "rotate:", 7)) {
@@ -525,6 +530,7 @@ static int __init fb_console_setup(char *this_opt)
 			} else {
 				printk(KERN_WARNING "fbcon: rotate: incorrect value.\n");
 			}
+			continue;
 		}
 	}
 	return 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/4] fbcon: optimize parameters parsing loop.
@ 2012-07-24  1:00   ` Paul Cercueil
  0 siblings, 0 replies; 13+ messages in thread
From: Paul Cercueil @ 2012-07-24  1:00 UTC (permalink / raw)
  To: FlorianSchandinat; +Cc: linux-kernel, linux-fbdev, Paul Cercueil


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/video/console/fbcon.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 9b83b75..1ecaf68 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -441,8 +441,10 @@ static int __init fb_console_setup(char *this_opt)
 		return 1;
 
 	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
 			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}
 		
 		if (!strncmp(options, "scrollback:", 11)) {
 			char *k;
@@ -468,6 +470,7 @@ static int __init fb_console_setup(char *this_opt)
 			/* (k && *k): Check for garbage after the suffix */
 			if (ret || (k && *k))
 				printk(KERN_WARNING "fbcon: scrollback: incorrect value.\n");
+			continue;
 		}
 		
 		if (!strncmp(options, "map:", 4)) {
@@ -484,6 +487,7 @@ static int __init fb_console_setup(char *this_opt)
 			} else {
 				printk(KERN_WARNING "fbcon: map: incorrect value.\n");
 			}
+			continue;
 		}
 
 		if (!strncmp(options, "vc:", 3)) {
@@ -513,6 +517,7 @@ static int __init fb_console_setup(char *this_opt)
 				fbcon_is_default = 0;
 			else
 				printk(KERN_WARNING "fbcon: vc: incorrect value.\n");
+			continue;
 		}
 
 		if (!strncmp(options, "rotate:", 7)) {
@@ -525,6 +530,7 @@ static int __init fb_console_setup(char *this_opt)
 			} else {
 				printk(KERN_WARNING "fbcon: rotate: incorrect value.\n");
 			}
+			continue;
 		}
 	}
 	return 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
  2012-07-24  1:00   ` Paul Cercueil
@ 2012-07-25 14:13     ` paul
  -1 siblings, 0 replies; 13+ messages in thread
From: paul @ 2012-07-25 14:13 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev

Oh, I'm really sorry, I truely am.
It looks like that 4th patch is an old version, not the one that should 
have been sent.

Next message will be the correct patch. My apologies about that.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
@ 2012-07-25 14:13     ` paul
  0 siblings, 0 replies; 13+ messages in thread
From: paul @ 2012-07-25 14:13 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev

Oh, I'm really sorry, I truely am.
It looks like that 4th patch is an old version, not the one that should 
have been sent.

Next message will be the correct patch. My apologies about that.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
  2012-07-24  1:00   ` Paul Cercueil
@ 2012-07-25 14:14     ` paul
  -1 siblings, 0 replies; 13+ messages in thread
From: paul @ 2012-07-25 14:14 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev

 From 67cecd09d850542e00a1d9a29567232d1224cf23 Mon Sep 17 00:00:00 2001
 From: Paul Cercueil <paul@crapouillou.net>
Date: Thu, 12 Jan 2012 19:40:24 +0100
Subject: [PATCH 4/4] fbcon: optimize parameters parsing loop.


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
  drivers/video/console/fbcon.c |    8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c 
b/drivers/video/console/fbcon.c
index 9b83b75..1ecaf68 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -441,8 +441,10 @@ static int __init fb_console_setup(char *this_opt)
  		return 1;

  	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
  			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}

  		if (!strncmp(options, "scrollback:", 11)) {
  			char *k;
@@ -468,6 +470,7 @@ static int __init fb_console_setup(char *this_opt)
  			/* (k && *k): Check for garbage after the suffix */
  			if (ret || (k && *k))
  				pr_warn("fbcon: scrollback: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "map:", 4)) {
@@ -484,6 +487,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: map: incorrect value.\n");
  			}
+			continue;
  		}

  		if (!strncmp(options, "vc:", 3)) {
@@ -513,6 +517,7 @@ static int __init fb_console_setup(char *this_opt)
  				fbcon_is_default = 0;
  			else
  				pr_warn("fbcon: vc: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "rotate:", 7)) {
@@ -525,6 +530,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: rotate: incorrect value.\n");
  			}
+			continue;
  		}
  	}
  	return 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] fbcon: optimize parameters parsing loop.
@ 2012-07-25 14:14     ` paul
  0 siblings, 0 replies; 13+ messages in thread
From: paul @ 2012-07-25 14:14 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: florianschandinat, linux-kernel, linux-fbdev

 From 67cecd09d850542e00a1d9a29567232d1224cf23 Mon Sep 17 00:00:00 2001
 From: Paul Cercueil <paul@crapouillou.net>
Date: Thu, 12 Jan 2012 19:40:24 +0100
Subject: [PATCH 4/4] fbcon: optimize parameters parsing loop.


Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
  drivers/video/console/fbcon.c |    8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/console/fbcon.c 
b/drivers/video/console/fbcon.c
index 9b83b75..1ecaf68 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -441,8 +441,10 @@ static int __init fb_console_setup(char *this_opt)
  		return 1;

  	while ((options = strsep(&this_opt, ",")) != NULL) {
-		if (!strncmp(options, "font:", 5))
+		if (!strncmp(options, "font:", 5)) {
  			strlcpy(fontname, options + 5, sizeof(fontname));
+			continue;
+		}

  		if (!strncmp(options, "scrollback:", 11)) {
  			char *k;
@@ -468,6 +470,7 @@ static int __init fb_console_setup(char *this_opt)
  			/* (k && *k): Check for garbage after the suffix */
  			if (ret || (k && *k))
  				pr_warn("fbcon: scrollback: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "map:", 4)) {
@@ -484,6 +487,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: map: incorrect value.\n");
  			}
+			continue;
  		}

  		if (!strncmp(options, "vc:", 3)) {
@@ -513,6 +517,7 @@ static int __init fb_console_setup(char *this_opt)
  				fbcon_is_default = 0;
  			else
  				pr_warn("fbcon: vc: incorrect value.\n");
+			continue;
  		}

  		if (!strncmp(options, "rotate:", 7)) {
@@ -525,6 +530,7 @@ static int __init fb_console_setup(char *this_opt)
  			} else {
  				pr_warn("fbcon: rotate: incorrect value.\n");
  			}
+			continue;
  		}
  	}
  	return 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] fbcon: prevent possible buffer overflow.
  2012-07-24  1:00   ` Paul Cercueil
  (?)
@ 2012-08-23 20:28   ` Florian Tobias Schandinat
  -1 siblings, 0 replies; 13+ messages in thread
From: Florian Tobias Schandinat @ 2012-08-23 20:28 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: linux-kernel, linux-fbdev

On 07/24/2012 01:00 AM, Paul Cercueil wrote:
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Applied.


Thanks,

Florian Tobias Schandinat

> ---
>  drivers/video/console/fbcon.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
> index a0b1818..3ffab97 100644
> --- a/drivers/video/console/fbcon.c
> +++ b/drivers/video/console/fbcon.c
> @@ -442,7 +442,7 @@ static int __init fb_console_setup(char *this_opt)
>  
>  	while ((options = strsep(&this_opt, ",")) != NULL) {
>  		if (!strncmp(options, "font:", 5))
> -			strcpy(fontname, options + 5);
> +			strlcpy(fontname, options + 5, sizeof(fontname));
>  		
>  		if (!strncmp(options, "scrollback:", 11)) {
>  			char *k;


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-08-23 20:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24  1:00 [PATCH 1/4] fbcon: use kstrtouint instead of deprecated function simple_strtoul Paul Cercueil
2012-07-24  1:00 ` Paul Cercueil
2012-07-24  1:00 ` [PATCH 2/4] fbcon: prevent possible buffer overflow Paul Cercueil
2012-07-24  1:00   ` Paul Cercueil
2012-08-23 20:28   ` Florian Tobias Schandinat
2012-07-24  1:00 ` [PATCH 3/4] fbcon: continue parsing parameters after an error Paul Cercueil
2012-07-24  1:00   ` Paul Cercueil
2012-07-24  1:00 ` [PATCH 4/4] fbcon: optimize parameters parsing loop Paul Cercueil
2012-07-24  1:00   ` Paul Cercueil
2012-07-25 14:13   ` paul
2012-07-25 14:13     ` paul
2012-07-25 14:14   ` paul
2012-07-25 14:14     ` paul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.