diff mbox

[v2] PM / hibernate: memory corruption in resumedelay_setup()

Message ID 20140514160845.GA5273@mwanda (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter May 14, 2014, 4:08 p.m. UTC
In the original code "resume_delay" is an int so on 64 bits, the call to
kstrtoul() will cause memory corruption.  We may as well fix a style
issue here as well and make "resume_delay" unsigned int, since that's
what we pass to ssleep().

Fixes: 317cf7e5e85e ('PM / hibernate: convert simple_strtoul to kstrtoul')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: style differences

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pavel Machek May 14, 2014, 8:29 p.m. UTC | #1
On Wed 2014-05-14 19:08:46, Dan Carpenter wrote:
> In the original code "resume_delay" is an int so on 64 bits, the call to
> kstrtoul() will cause memory corruption.  We may as well fix a style
> issue here as well and make "resume_delay" unsigned int, since that's
> what we pass to ssleep().

> Fixes: 317cf7e5e85e ('PM / hibernate: convert simple_strtoul to kstrtoul')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

And thanks :-).
								Pavel
Rafael J. Wysocki May 19, 2014, 11:23 p.m. UTC | #2
On Wednesday, May 14, 2014 10:29:47 PM Pavel Machek wrote:
> On Wed 2014-05-14 19:08:46, Dan Carpenter wrote:
> > In the original code "resume_delay" is an int so on 64 bits, the call to
> > kstrtoul() will cause memory corruption.  We may as well fix a style
> > issue here as well and make "resume_delay" unsigned int, since that's
> > what we pass to ssleep().
> 
> > Fixes: 317cf7e5e85e ('PM / hibernate: convert simple_strtoul to kstrtoul')
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>

Queued up for 3.16, thanks!
diff mbox

Patch

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 2377ff7..df88d55 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -35,7 +35,7 @@ 
 static int nocompress;
 static int noresume;
 static int resume_wait;
-static int resume_delay;
+static unsigned int resume_delay;
 static char resume_file[256] = CONFIG_PM_STD_PARTITION;
 dev_t swsusp_resume_device;
 sector_t swsusp_resume_block;
@@ -1115,7 +1115,7 @@  static int __init resumewait_setup(char *str)
 
 static int __init resumedelay_setup(char *str)
 {
-	int rc = kstrtoul(str, 0, (unsigned long *)&resume_delay);
+	int rc = kstrtouint(str, 0, &resume_delay);
 
 	if (rc)
 		return rc;