block: null_blk: fix use after free
authorMing Lei <tom.leiming@gmail.com>
Thu, 1 May 2014 07:12:36 +0000 (15:12 +0800)
committerJens Axboe <axboe@fb.com>
Thu, 1 May 2014 15:17:41 +0000 (09:17 -0600)
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 <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/null_blk.c

index 8e7e3a0b0d24834ed46e6cd5c3f47c444b016733..e932398588aa187fda13a728c48b67c2cd9c64f5 100644 (file)
@@ -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);
        }