From 9672e6d7bf4f18776d8bd60a7198f24948355c47 Mon Sep 17 00:00:00 2001 From: Hajime Tazaki Date: Fri, 17 Jul 2015 15:13:04 +0900 Subject: [PATCH] lib: add more strict sanity checks for del_timer() Signed-off-by: Hajime Tazaki --- arch/lib/timer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/lib/timer.c b/arch/lib/timer.c index 0c9a78defd40..d290e3721841 100644 --- a/arch/lib/timer.c +++ b/arch/lib/timer.c @@ -185,22 +185,24 @@ int del_timer(struct timer_list *timer) int retval; struct lib_timer *l_timer; - if (timer->entry.pprev == 0) + if (timer->entry.pprev == NULL) return 0; l_timer = lib_timer_find(timer); if (l_timer != NULL && l_timer->event != NULL) { lib_event_cancel(l_timer->event); - if (l_timer->t_hash.next != LIST_POISON1) + if (l_timer->t_hash.next != LIST_POISON1) { hlist_del(&l_timer->t_hash); - lib_free(l_timer); + lib_free(l_timer); + } retval = 1; } else { retval = 0; } - hlist_del(&timer->entry); + if (timer->entry.next != LIST_POISON1) + hlist_del(&timer->entry); timer->entry.pprev = NULL; return retval; }