wakeup: Add the guard condition for len in pm_get_active_wakeup_sources
authorRuchi Kandoi <kandoiruchi@google.com>
Tue, 10 Nov 2015 18:53:55 +0000 (10:53 -0800)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:54:24 +0000 (13:54 -0800)
Check if the len is not greater than maximum to prevent buffer overflow.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Change-Id: I575b0a72bb5448b68353408d71fa8b83420c9088

drivers/base/power/wakeup.c

index 305d6dd6bdefaf0b7343e852fa54a14d7450111c..09c07f519952d7afa342fb8e1156c6f15497f9c8 100644 (file)
@@ -813,7 +813,7 @@ void pm_get_active_wakeup_sources(char *pending_wakeup_source, size_t max)
 
        rcu_read_lock();
        list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-               if (ws->active) {
+               if (ws->active && len < max) {
                        if (!active)
                                len += scnprintf(pending_wakeup_source, max,
                                                "Pending Wakeup Sources: ");