linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: vmscan: add VM_BUG_ON on illegal return values from scan_objects
@ 2013-05-21  7:13 Oskar Andero
  2013-05-21  7:17 ` Pekka Enberg
  0 siblings, 1 reply; 3+ messages in thread
From: Oskar Andero @ 2013-05-21  7:13 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Radovan Lekanovic, David Rientjes, Oskar Andero, Glauber Costa,
	Dave Chinner, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

Add a VM_BUG_ON to catch any illegal value from the shrinkers. It's a
potential bug if scan_objects returns a negative other than -1 and
would lead to undefined behaviour.

Cc: Glauber Costa <glommer@openvz.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
---
 mm/vmscan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6bac41e..63fec86 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
 		ret = shrinker->scan_objects(shrinker, shrinkctl);
 		if (ret == -1)
 			break;
+		VM_BUG_ON(ret < -1);
 		freed += ret;
 
 		count_vm_events(SLABS_SCANNED, nr_to_scan);
-- 
1.8.1.5

--
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-21  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21  7:13 [PATCH v2] mm: vmscan: add VM_BUG_ON on illegal return values from scan_objects Oskar Andero
2013-05-21  7:17 ` Pekka Enberg
2013-05-21  7:28   ` Glauber Costa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox