public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] UBI: Fix check on unsigned in ytes_str_to_int()
@ 2009-10-16 12:00 Roel Kluin
  2009-10-20  7:20 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-10-16 12:00 UTC (permalink / raw)
  To: Artem Bityutskiy, linux-mtd, Andrew Morton

result is unsigned, the wrong check was used.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index e1f7d0a..14cec04 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -42,6 +42,7 @@
 #include <linux/log2.h>
 #include <linux/kthread.h>
 #include <linux/reboot.h>
+#include <linux/kernel.h>
 #include "ubi.h"
 
 /* Maximum length of the 'mtd=' parameter */
@@ -1257,7 +1258,7 @@ static int __init bytes_str_to_int(const char *str)
 	unsigned long result;
 
 	result = simple_strtoul(str, &endp, 0);
-	if (str == endp || result < 0) {
+	if (str == endp || result >= INT_MAX) {
 		printk(KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n",
 		       str);
 		return -EINVAL;

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

* Re: [PATCH] UBI: Fix check on unsigned in ytes_str_to_int()
  2009-10-16 12:00 [PATCH] UBI: Fix check on unsigned in ytes_str_to_int() Roel Kluin
@ 2009-10-20  7:20 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2009-10-20  7:20 UTC (permalink / raw)
  To: Roel Kluin; +Cc: Andrew Morton, linux-mtd

On Fri, 2009-10-16 at 14:00 +0200, Roel Kluin wrote:
> result is unsigned, the wrong check was used.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index e1f7d0a..14cec04 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -42,6 +42,7 @@
>  #include <linux/log2.h>
>  #include <linux/kthread.h>
>  #include <linux/reboot.h>
> +#include <linux/kernel.h>
>  #include "ubi.h"
>  
>  /* Maximum length of the 'mtd=' parameter */
> @@ -1257,7 +1258,7 @@ static int __init bytes_str_to_int(const char *str)
>  	unsigned long result;
>  
>  	result = simple_strtoul(str, &endp, 0);
> -	if (str == endp || result < 0) {
> +	if (str == endp || result >= INT_MAX) {
>  		printk(KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n",
>  		       str);
>  		return -EINVAL;

Pushed to ubi-2.6 tree, will send to Linus soon, thanks.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

end of thread, other threads:[~2009-10-20  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-16 12:00 [PATCH] UBI: Fix check on unsigned in ytes_str_to_int() Roel Kluin
2009-10-20  7:20 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox