From patchwork Tue May 28 15:47:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Schmidt X-Patchwork-Id: 2625631 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D7C4F4020A for ; Tue, 28 May 2013 15:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934622Ab3E1Prr (ORCPT ); Tue, 28 May 2013 11:47:47 -0400 Received: from xp-ob.rzone.de ([81.169.146.137]:24214 "EHLO xp-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934579Ab3E1Prq (ORCPT ); Tue, 28 May 2013 11:47:46 -0400 X-RZG-CLASS-ID: xp Received: from pizpot.store ([192.168.43.236]) by joses.store (joses xp3) (RZmta 31.27 OK) with ESMTP id p06cbep4S8RCKo for ; Tue, 28 May 2013 17:47:44 +0200 (CEST) From: Jan Schmidt To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/3] Btrfs: avoid double free of fs_info->qgroup_ulist Date: Tue, 28 May 2013 17:47:23 +0200 Message-Id: <1369756044-17194-3-git-send-email-list.btrfs@jan-o-sch.net> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1369756044-17194-1-git-send-email-list.btrfs@jan-o-sch.net> References: <1369756044-17194-1-git-send-email-list.btrfs@jan-o-sch.net> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org When btrfs_read_qgroup_config or btrfs_quota_enable return non-zero, we've already freed the fs_info->qgroup_ulist. The final btrfs_free_qgroup_config called from quota_disable makes another ulist_free(fs_info->qgroup_ulist) call. We set fs_info->qgroup_ulist to NULL on the mentioned error paths, turning the ulist_free in btrfs_free_qgroup_config into a noop. Cc: Wang Shilong Signed-off-by: Jan Schmidt --- fs/btrfs/qgroup.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 74b432d..c6ce642 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -430,8 +430,10 @@ out: } btrfs_free_path(path); - if (ret < 0) + if (ret < 0) { ulist_free(fs_info->qgroup_ulist); + fs_info->qgroup_ulist = NULL; + } return ret < 0 ? ret : 0; } @@ -932,8 +934,10 @@ out_free_root: kfree(quota_root); } out: - if (ret) + if (ret) { ulist_free(fs_info->qgroup_ulist); + fs_info->qgroup_ulist = NULL; + } mutex_unlock(&fs_info->qgroup_ioctl_lock); return ret; }