From patchwork Wed Apr 9 00:18:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 3951841 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 64FDB9F369 for ; Wed, 9 Apr 2014 00:19:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DF54204AD for ; Wed, 9 Apr 2014 00:19:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC7622039C for ; Wed, 9 Apr 2014 00:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756890AbaDIATa (ORCPT ); Tue, 8 Apr 2014 20:19:30 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:41588 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756778AbaDIAT3 (ORCPT ); Tue, 8 Apr 2014 20:19:29 -0400 Received: from m1.gw.fujitsu.co.jp (unknown [10.0.50.71]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 964EB3EE0B6 for ; Wed, 9 Apr 2014 09:19:28 +0900 (JST) Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 8964A45DE55 for ; Wed, 9 Apr 2014 09:19:28 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.nic.fujitsu.com [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 73D7345DE54 for ; Wed, 9 Apr 2014 09:19:28 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 64C661DB8045 for ; Wed, 9 Apr 2014 09:19:28 +0900 (JST) Received: from m1001.s.css.fujitsu.com (m1001.s.css.fujitsu.com [10.240.81.139]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 16B201DB8042 for ; Wed, 9 Apr 2014 09:19:28 +0900 (JST) Received: from m1001.css.fujitsu.com (m1001 [127.0.0.1]) by m1001.s.css.fujitsu.com (Postfix) with ESMTP id DFD3561F9F; Wed, 9 Apr 2014 09:19:27 +0900 (JST) Received: from WIN-R1VKH1IH438.jp.fujitsu.com (unknown [10.124.102.85]) by m1001.s.css.fujitsu.com (Postfix) with SMTP id 9924A61F90; Wed, 9 Apr 2014 09:19:27 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.2.0 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20131115 Message-Id: <201404090018.AA00003@WIN-R1VKH1IH438.jp.fujitsu.com> From: Tsutomu Itoh Date: Wed, 09 Apr 2014 09:18:04 +0900 To: linux-btrfs@vger.kernel.org Cc: alex@zadarastorage.com Subject: [PATCH] Btrfs: fix possible memory leak in btrfs_create_tree() MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 In btrfs_create_tree(), if btrfs_insert_root() fails, we should free root->commit_root. Reported-by: Alex Lyakas Signed-off-by: Tsutomu Itoh --- fs/btrfs/disk-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6d1ac7d..a35d7fb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1374,6 +1374,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, fail: if (leaf) { btrfs_tree_unlock(leaf); + free_extent_buffer(root->commit_root); free_extent_buffer(leaf); } kfree(root);