Skip to content

Commit

Permalink
vmscan.c: fix invalid strict_strtoul() check in write_scan_unevictabl…
Browse files Browse the repository at this point in the history
…e_node()

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 <[email protected]>
Reviewed-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Lee Schermerhorn <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Kautuk Consul authored and torvalds committed Nov 1, 2011
1 parent 4e9dc5d commit 3f38099
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3520,8 +3520,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))
Expand Down

0 comments on commit 3f38099

Please sign in to comment.