diff options
author | Signed-off by Yi Yang <yi.y.yang@intel.com> | 2007-12-28 03:50:42 +0100 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-12-28 04:19:27 +0100 |
commit | 975c30257e75c3d067d4858f60963b80fc6bd0e4 (patch) | |
tree | 27c64337e2109c0704ae6a47a6169618dfb64dea | |
parent | Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 (diff) | |
download | linux-975c30257e75c3d067d4858f60963b80fc6bd0e4.tar.xz linux-975c30257e75c3d067d4858f60963b80fc6bd0e4.zip |
ACPI: detect invalid argument written to /proc/acpi/alarm
/proc/acpi/alarm can't be set correctly, here is a sample:
[root@localhost /]# echo "2006 09" > /proc/acpi/alarm
[root@localhost /]# cat /proc/acpi/alarm
2007-12-09 09:09:09
[root@localhost /]# echo "2006 04" > /proc/acpi/alarm
[root@localhost /]# cat /proc/acpi/alarm
2007-12-04 04:04:04
[root@localhost /]#
Obviously, it is wrong, it should consider it as an invalid input.
after this patch:
[root@localhost /]# echo "2008 09" > /proc/acpi/alarm
-bash: echo: write error: Invalid argument
[root@localhost /]#
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/sleep/proc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 1538355c266b..fce78fbf5f64 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -178,6 +178,9 @@ static int get_date_field(char **p, u32 * value) * Try to find delimeter, only to insert null. The end of the * string won't have one, but is still valid. */ + if (*p == NULL) + return result; + next = strpbrk(*p, "- :"); if (next) *next++ = '\0'; @@ -190,6 +193,8 @@ static int get_date_field(char **p, u32 * value) if (next) *p = next; + else + *p = NULL; return result; } |