From patchwork Wed Dec 14 14:05:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 9474225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F08D760824 for ; Wed, 14 Dec 2016 14:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E06CE286FE for ; Wed, 14 Dec 2016 14:06:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3E322870D; Wed, 14 Dec 2016 14:06:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE5D82870D for ; Wed, 14 Dec 2016 14:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755529AbcLNOFz (ORCPT ); Wed, 14 Dec 2016 09:05:55 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:44462 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755502AbcLNOFw (ORCPT ); Wed, 14 Dec 2016 09:05:52 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1cHABV-0002Jn-2L; Wed, 14 Dec 2016 15:05:29 +0100 From: Sebastian Andrzej Siewior To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior Subject: [PATCH 2/2] btrfs: swap free() and trace point in run_ordered_work() Date: Wed, 14 Dec 2016 15:05:30 +0100 Message-Id: <20161214140530.6534-2-bigeasy@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161214140530.6534-1-bigeasy@linutronix.de> References: <20161214140530.6534-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The previous patch removed a trace point due to a use after free problem with tracing enabled. While looking at the backtrace it took me a while to find the right spot. While doing so I noticed that this trace point could be used after one of two clean-up functions were invoked: - run_one_async_free() - async_cow_free() Both of them free the `work' item so a later use in the tracepoint is not possible. This patch swaps the order so we first have the trace point and then free the struct. Signed-off-by: Sebastian Andrzej Siewior --- fs/btrfs/async-thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index d0dfc3d2e199..6f4631bf74f8 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -288,8 +288,8 @@ static void run_ordered_work(struct __btrfs_workqueue *wq) * we don't want to call the ordered free functions * with the lock held though */ - work->ordered_free(work); trace_btrfs_all_work_done(work); + work->ordered_free(work); } spin_unlock_irqrestore(lock, flags); }