From: Qu Wenruo Date: Fri, 22 Jan 2016 01:28:38 +0000 (+0800) Subject: btrfs: async-thread: Fix a use-after-free error for trace X-Git-Tag: v4.1.22~154 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9a54ed91c7bbd5c18a4170be078d9f7e28560ed;p=platform%2Fkernel%2Flinux-exynos.git btrfs: async-thread: Fix a use-after-free error for trace [ Upstream commit 0a95b851370b84a4b9d92ee6d1fa0926901d0454 ] Parameter of trace_btrfs_work_queued() can be freed in its workqueue. So no one use use that pointer after queue_work(). Fix the user-after-free bug by move the trace line before queue_work(). Reported-by: Dave Jones Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: Chris Mason Signed-off-by: Sasha Levin --- diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index df9932b..1848705 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -316,8 +316,8 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, list_add_tail(&work->ordered_list, &wq->ordered_list); spin_unlock_irqrestore(&wq->list_lock, flags); } - queue_work(wq->normal_wq, &work->normal_work); trace_btrfs_work_queued(work); + queue_work(wq->normal_wq, &work->normal_work); } void btrfs_queue_work(struct btrfs_workqueue *wq,