Skip to contentSkip to conversation

Fixed couple of unreachable code segments asus_acpi.c

PATCH In review ville palo 2 participants 4 messages Aug 23, 2006 – Aug 24, 2006

Subsystems (2)
lore
Share & tools
lore

ville palo

author
#0 lore raw

PATCH 1/1 Fixed couple of unreachable code segments asus_acpi.c

Fixed couple of unreachable code segments:

drivers/acpi/asus_acpi.c +16 -13
index e9ee4c5..c1f2356 100644
@@ -608,19 +608,20 @@ proc_write_ledd(struct file *file, const
 		unsigned long count, void *data)
 {
 	int value;
-
-	count = parse_arg(buffer, count, &value);
-	if (count > 0) {
+	int result;
+	
+	result = parse_arg(buffer, count, &value);
+	if (result > 0) {
 		if (!write_acpi_int
 		    (hotk->handle, hotk->methods->mt_ledd, value, NULL))
 			printk(KERN_WARNING
 			       "Asus ACPI: LED display write failed\n");
 		else
 			hotk->ledd_status = (u32) value;
-	} else if (count < 0)
+	} else if (result < 0)
 		printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
 
-	return count;
+	return result;
 }
 
 /*
@@ -831,17 +832,18 @@ proc_write_brn(struct file *file, const 
 	       unsigned long count, void *data)
 {
 	int value;
+	int result;
 
-	count = parse_arg(buffer, count, &value);
-	if (count > 0) {
+	result = parse_arg(buffer, count, &value);
+	if (result > 0) {
 		value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
 		/* 0 <= value <= 15 */
 		set_brightness(value);
-	} else if (count < 0) {
+	} else if (result < 0) {
 		printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
 	}
 
-	return count;
+	return result;
 }
 
 static void set_display(int value)
@@ -881,14 +883,15 @@ proc_write_disp(struct file *file, const
 		unsigned long count, void *data)
 {
 	int value;
+	int result;
 
-	count = parse_arg(buffer, count, &value);
-	if (count > 0)
+	result = parse_arg(buffer, count, &value);
+	if (result > 0)
 		set_display(value);
-	else if (count < 0)
+	else if (result < 0)
 		printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
 
-	return count;
+	return result;
 }
 
 typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

Re: [KJ] [PATCH] Fixed couple of unreachable code segments

Quoted 1 line · ville palo

Fixed couple of unreachable code segments:

But it _should_ be reachable!

parse_arg() returns errors

	static int parse_arg(const char __user * buf, unsigned long count, int *val)
	{
		char s[32];
		if (!count)
			return 0;
		if (count > 31)
			return -EINVAL;
		if (copy_from_user(s, buf, count))
			return -EFAULT;
		s[count] = 0;
		if (sscanf(s, "%i", val) != 1)
			return -EINVAL;
		return count;
	}

I have a gut feeling someone already send a patch correcting the situation...

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

Re: [KJ] [PATCH] Fixed couple of unreachable code segments

In reply to ville palo
Quoted 22 lines · Alexey Dobriyan
Quoted 1 line · ville palo

Fixed couple of unreachable code segments:

But it _should_ be reachable!

parse_arg() returns errors

	static int parse_arg(const char __user * buf, unsigned long count, int *val)
	{
		char s[32];
		if (!count)
			return 0;
		if (count > 31)
			return -EINVAL;
		if (copy_from_user(s, buf, count))
			return -EFAULT;
		s[count] = 0;
		if (sscanf(s, "%i", val) != 1)
			return -EINVAL;
		return count;
	}
Quoted 2 lines

I have a gut feeling someone already send a patch correcting the situation...

Here it is, will send to akpm in a minute

[KJ][Patch] corrset useage of negative number in an unsigned long in asus_acpi.c (sic) Darren Jenkins

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

author
#3 lore raw

Re: [KJ] [PATCH] Fixed couple of unreachable code

In reply to ville palo
Quoted 5 lines · Alexey Dobriyan
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · ville palo

Fixed couple of unreachable code segments:

But it _should_ be reachable!

Yes, it should :)

Quoted 18 lines
Quoted 18 lines

parse_arg() returns errors

	static int parse_arg(const char __user * buf, unsigned long count, int *val)
	{
		char s[32];
		if (!count)
			return 0;
		if (count > 31)
			return -EINVAL;
		if (copy_from_user(s, buf, count))
			return -EFAULT;
		s[count] = 0;
		if (sscanf(s, "%i", val) != 1)
			return -EINVAL;
		return count;
	}
Quoted 8 lines
Quoted 2 lines

I have a gut feeling someone already send a patch correcting the situation...

Here it is, will send to akpm in a minute

[KJ][Patch] corrset useage of negative number in an unsigned long in asus_acpi.c (sic) Darren Jenkins

Only difference between these patches is that when parse_arg returns an error, in Darren Jenkins patch it is written to the log, but not returned to the caller. And proc_write_led function was not corrected in Darrens patch.

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors