From patchwork Wed May 8 08:10:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2537821 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 B80573FC5A for ; Wed, 8 May 2013 08:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752342Ab3EHIKA (ORCPT ); Wed, 8 May 2013 04:10:00 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:19404 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751863Ab3EHIJ6 (ORCPT ); Wed, 8 May 2013 04:09:58 -0400 X-IronPort-AV: E=Sophos;i="4.87,633,1363104000"; d="scan'208";a="7215064" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 08 May 2013 16:07:05 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r4889rTD019759 for ; Wed, 8 May 2013 16:09:53 +0800 Received: from [127.0.0.1] ([10.167.233.203]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013050816085785-1080220 ; Wed, 8 May 2013 16:08:57 +0800 Message-ID: <518A0871.5090907@cn.fujitsu.com> Date: Wed, 08 May 2013 16:10:25 +0800 From: Wang Shilong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Linux Btrfs Subject: [PATCH] Btrfs: fix possible memory leak in the find_parent_nodes() X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/08 16:08:58, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/08 16:08:58, Serialize complete at 2013/05/08 16:08:58 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In the find_parent_nodes(), if read_tree_block() fails, we can not return directly, we should free some allocated memory otherwise memory leak happens. Signed-off-by: Wang Shilong --- Since Chris has already setup his pull, we'd like to send another patch. --- fs/btrfs/backref.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index b4fb415..290e347 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -918,7 +918,8 @@ again: ref->parent, bsz, 0); if (!eb || !extent_buffer_uptodate(eb)) { free_extent_buffer(eb); - return -EIO; + ret = -EIO; + goto out; } ret = find_extent_in_eb(eb, bytenr, *extent_item_pos, &eie);