]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vmscan.c: fix invalid strict_strtoul() check in write_scan_unevictable_node()
authorKautuk Consul <consul.kautuk@gmail.com>
Wed, 28 Sep 2011 00:50:26 +0000 (10:50 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 4 Oct 2011 07:38:40 +0000 (18:38 +1100)
write_scan_unevictable_node() checks the value req returned by
strict_strtoul() and returns 1 if req is 0.

However, when strict_strtoul() returns 0, it means successful conversion
of buf to unsigned long.

Due to this, the function was not proceeding to scan the zones for
unevictable pages even though we write a valid value to the
scan_unevictable_pages sys file.

Change this check slightly to check for invalid value in buf as well as 0
value stored in res after successful conversion via strict_strtoul.  In
both cases, we do not perform the scanning of this node's zones.

Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <jweiner@redhat.com>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: Andrew Morton <>
mm/vmscan.c

index f94eb0b628f09fd934a9b1e8f9ff66ff1ab7b749..13818fabef6790714865c753a660b98bfe106d84 100644 (file)
@@ -3503,8 +3503,8 @@ static ssize_t write_scan_unevictable_node(struct sys_device *dev,
        unsigned long res;
        unsigned long req = strict_strtoul(buf, 10, &res);
 
-       if (!req)
-               return 1;       /* zero is no-op */
+       if (req || !res)
+               return 1; /* Invalid input or zero is no-op */
 
        for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
                if (!populated_zone(zone))