Skip to content

Commit

Permalink
lib: add more strict sanity checks for del_timer()
Browse files Browse the repository at this point in the history
Signed-off-by: Hajime Tazaki <[email protected]>
  • Loading branch information
Hajime Tazaki authored and thehajime committed Jul 17, 2015
1 parent 4977649 commit 9672e6d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arch/lib/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9672e6d

Please sign in to comment.