OSDN Git Service

drivers: qcom: lpm-stats: Fix undefined access error
authorMahesh Sivasubramanian <msivasub@codeaurora.org>
Wed, 7 Mar 2018 23:00:07 +0000 (16:00 -0700)
committerMaulik Shah <mkshah@codeaurora.org>
Fri, 16 Mar 2018 05:30:00 +0000 (11:00 +0530)
In cleanup_stats(), a freed memory pointer pos might be accessed for
list traversal. Switch to using _safe() variant of the list API to
prevent undefined accesses.

Change-Id: I7d068cb7813ccb9bfdbcab4646b4ec890145828a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
drivers/power/qcom/lpm-stats.c

index 90458d6..4605625 100644 (file)
@@ -682,9 +682,10 @@ static void cleanup_stats(struct lpm_stats *stats)
 {
        struct list_head *centry = NULL;
        struct lpm_stats *pos = NULL;
+       struct lpm_stats *n = NULL;
 
        centry = &stats->child;
-       list_for_each_entry_reverse(pos, centry, sibling) {
+       list_for_each_entry_safe_reverse(pos, n, centry, sibling) {
                if (!list_empty(&pos->child)) {
                        cleanup_stats(pos);
                        continue;