* [KJ] [PATCH] Fixed couple of unreachable code segments asus_acpi.c
@ 2006-08-23 18:48 ville palo
2006-08-23 22:56 ` [KJ] [PATCH] Fixed couple of unreachable code segments Alexey Dobriyan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ville palo @ 2006-08-23 18:48 UTC (permalink / raw)
To: kernel-janitors
Fixed couple of unreachable code segments:
Signed-off-by: Ville Palo <ville.palo@vi64pa.net>
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index e9ee4c5..c1f2356 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [KJ] [PATCH] Fixed couple of unreachable code segments
2006-08-23 18:48 [KJ] [PATCH] Fixed couple of unreachable code segments asus_acpi.c ville palo
@ 2006-08-23 22:56 ` Alexey Dobriyan
2006-08-23 23:00 ` Alexey Dobriyan
2006-08-24 5:38 ` [KJ] [PATCH] Fixed couple of unreachable code ville palo
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2006-08-23 22:56 UTC (permalink / raw)
To: kernel-janitors
On Wed, Aug 23, 2006 at 09:48:15PM +0300, ville palo wrote:
> 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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] [PATCH] Fixed couple of unreachable code segments
2006-08-23 18:48 [KJ] [PATCH] Fixed couple of unreachable code segments asus_acpi.c ville palo
2006-08-23 22:56 ` [KJ] [PATCH] Fixed couple of unreachable code segments Alexey Dobriyan
@ 2006-08-23 23:00 ` Alexey Dobriyan
2006-08-24 5:38 ` [KJ] [PATCH] Fixed couple of unreachable code ville palo
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2006-08-23 23:00 UTC (permalink / raw)
To: kernel-janitors
On Thu, Aug 24, 2006 at 02:56:03AM +0400, Alexey Dobriyan wrote:
> On Wed, Aug 23, 2006 at 09:48:15PM +0300, ville palo wrote:
> > 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...
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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [KJ] [PATCH] Fixed couple of unreachable code
2006-08-23 18:48 [KJ] [PATCH] Fixed couple of unreachable code segments asus_acpi.c ville palo
2006-08-23 22:56 ` [KJ] [PATCH] Fixed couple of unreachable code segments Alexey Dobriyan
2006-08-23 23:00 ` Alexey Dobriyan
@ 2006-08-24 5:38 ` ville palo
2 siblings, 0 replies; 4+ messages in thread
From: ville palo @ 2006-08-24 5:38 UTC (permalink / raw)
To: kernel-janitors
On Thu, 2006-08-24 at 03:00 +0400, Alexey Dobriyan wrote:
> On Thu, Aug 24, 2006 at 02:56:03AM +0400, Alexey Dobriyan wrote:
> > On Wed, Aug 23, 2006 at 09:48:15PM +0300, ville palo wrote:
> > > Fixed couple of unreachable code segments:
> >
> > But it _should_ be reachable!
Yes, it should :)
> >
> > 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...
>
> 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
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-24 5:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-23 18:48 [KJ] [PATCH] Fixed couple of unreachable code segments asus_acpi.c ville palo
2006-08-23 22:56 ` [KJ] [PATCH] Fixed couple of unreachable code segments Alexey Dobriyan
2006-08-23 23:00 ` Alexey Dobriyan
2006-08-24 5:38 ` [KJ] [PATCH] Fixed couple of unreachable code ville palo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).