From patchwork Sat Jul 13 13:02:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2827165 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DE9EC0AB2 for ; Sat, 13 Jul 2013 13:03:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BB6B2011D for ; Sat, 13 Jul 2013 13:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9E9F2010E for ; Sat, 13 Jul 2013 13:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757837Ab3GMNDL (ORCPT ); Sat, 13 Jul 2013 09:03:11 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:37053 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753420Ab3GMNDL (ORCPT ); Sat, 13 Jul 2013 09:03:11 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz11so9771231pad.2 for ; Sat, 13 Jul 2013 06:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=ytsIqm3/ipi0SPY/HEBNVub+qKLXBm/3pjEG05mCM7Y=; b=bzrNSYE0hCJOhRUGsqKGjScHz+4GEeJ/i6HC17NcV3peIFFoXsGxxN/ymIZqO6FRHm 2UiklDJCd7lxMZfRo8T8lNqYwwdfoWiJPVTCe4DyJljTAvLdBEBVCuQEa/47KiKYBDdm K8NUhY1EkLnlcphlFTKomKFtObvOelOaldJBhRVyMXt+5TRCTWyDXchuvrkHFH7CLrHI IhfMXJ3PNPorZAQ2pJ5YnDjG5txzLZ2Msb2a1xHeCFmwFg7nKvUmZukQU3148zoRvlPe R1TSbhW3QgVbQQSspPUyym1FATE+aoGrt6c5ukIBx5J+YYO/pDSz/iA2kkQDFKUQM25B HsPw== X-Received: by 10.68.163.97 with SMTP id yh1mr46786233pbb.33.1373720590301; Sat, 13 Jul 2013 06:03:10 -0700 (PDT) Received: from localhost.localdomain.localdomain ([223.65.188.157]) by mx.google.com with ESMTPSA id vi8sm42084390pbc.31.2013.07.13.06.03.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 13 Jul 2013 06:03:09 -0700 (PDT) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: wangsl.fnst@cn.fujitsu.com, wangshilong1991@gmail.com Subject: [PATCH] Btrfs: set qgroup_ulist to be null after calling ulist_free() Date: Sat, 13 Jul 2013 21:02:54 +0800 Message-Id: <1373720574-23388-1-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong We call ulist_free(qgroup_ulist) in btrfs_free_qgroup_config(), and btrfs_free_qgroup_config() may be called in two cases: (1)umount filesystem (2)disabling quota However, if we firstly disable quota and then umount filesystem, a double free happens. Fix it. Signed-off-by: Wang Shilong --- fs/btrfs/qgroup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 1280eff..64a9e3c 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -460,7 +460,13 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info) } kfree(qgroup); } + /* + * we call btrfs_free_qgroup_config() when umounting + * filesystem and disabling quota, so we set qgroup_ulit + * to be null here to avoid double free. + */ ulist_free(fs_info->qgroup_ulist); + fs_info->qgroup_ulist = NULL; } static int add_qgroup_relation_item(struct btrfs_trans_handle *trans,