Thread (22 messages) 22 messages, 4 authors, 2014-02-06

Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c

From: Sebastian Capella <hidden>
Date: 2014-02-05 00:06:40
Also in: linux-mm

Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
quoted
Quoting Sebastian Capella (2014-02-04 14:37:33)
quoted
Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
quoted
quoted
 static int __init resumedelay_setup(char *str)
 {
-     resume_delay = simple_strtoul(str, NULL, 0);
+     int ret = kstrtoint(str, 0, &resume_delay);
+     /* mask must_check warn; on failure, leaves resume_delay unchanged */
+     (void)ret;
One unintended consequence of this change is that it'll now accept a
negative integer parameter.
Well, what about using kstrtouint(), then?
I was thinking of doing something like:

	int delay, res;
	res = kstrtoint(str, 0, &delay);
	if (!res && delay >= 0)
		resume_delay = delay;
	return 1;
Well, kstrtoint() is used in some security-sensitive places AFAICS, so it
really is better to check its return value in general.  The __must_check
reminds people about that.
Thanks!

Sebastian

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help