From patchwork Fri Jan 28 22:08:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 516021 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0SMJRYW006334 for ; Fri, 28 Jan 2011 22:19:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470Ab1A1WTY (ORCPT ); Fri, 28 Jan 2011 17:19:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3387 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986Ab1A1WTY (ORCPT ); Fri, 28 Jan 2011 17:19:24 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0SMJOFr018111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Jan 2011 17:19:24 -0500 Received: from test1244.test.redhat.com (test1244.test.redhat.com [10.10.10.244]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0SMJNe0003242 for ; Fri, 28 Jan 2011 17:19:23 -0500 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: fix some memory leak issues Date: Fri, 28 Jan 2011 17:08:42 -0500 Message-Id: <1296252522-3260-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 28 Jan 2011 22:19:27 +0000 (UTC) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 416eee8..8dba070 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -876,8 +876,10 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, pinned[0] = grab_cache_page(inode->i_mapping, first_index); if (!PageUptodate(pinned[0])) { ret = btrfs_readpage(NULL, pinned[0]); - if (ret) + if (ret) { + kfree(pages); return ret; + } wait_on_page_locked(pinned[0]); } else { unlock_page(pinned[0]); @@ -891,6 +893,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, if (ret) { if (pinned[0]) page_cache_release(pinned[0]); + kfree(pages); return ret; } wait_on_page_locked(pinned[1]); @@ -965,8 +968,10 @@ again: dirty_pages, pos, copied); if (ret) { + WARN_ON(1); btrfs_delalloc_release_space(inode, dirty_pages << PAGE_CACHE_SHIFT); + btrfs_drop_pages(pages, num_pages); break; } }