From: Ming Lei Date: Thu, 1 May 2014 07:12:36 +0000 (+0800) Subject: block: null_blk: fix use after free X-Git-Tag: firefly_0821_release~176^2~3465^2~50^2~23 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fc27691f3537a0df087214322467b642d1f6dedb;p=firefly-linux-kernel-4.4.55.git block: null_blk: fix use after free entry(cmd->ll_list) may belong to new request once end_cmd() returns, so fix the bug with the patch. Without the change, it is easy to observe oops when doing null_blk(timer) test. Signed-off-by: Ming Lei Signed-off-by: Jens Axboe --- diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 8e7e3a0b0d24..e932398588aa 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -203,8 +203,8 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer) entry = llist_reverse_order(entry); do { cmd = container_of(entry, struct nullb_cmd, ll_list); - end_cmd(cmd); entry = entry->next; + end_cmd(cmd); } while (entry); }