From patchwork Thu Mar 17 18:56:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Jansen X-Patchwork-Id: 641891 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 p2HIuEKM012649 for ; Thu, 17 Mar 2011 18:56:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755333Ab1CQS4F (ORCPT ); Thu, 17 Mar 2011 14:56:05 -0400 Received: from ysabell.rzone.de ([81.169.144.237]:45449 "EHLO ysabell.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755331Ab1CQS4D (ORCPT ); Thu, 17 Mar 2011 14:56:03 -0400 Received: from gargravarr.store (gargravarr.store [192.168.42.236]) by ysabell.rzone.de (Postfix) with ESMTP id CE921E66; Thu, 17 Mar 2011 19:56:00 +0100 (MET) Received: by gargravarr.store (Postfix, from userid 32466) id B3082C075; Thu, 17 Mar 2011 19:56:00 +0100 (CET) From: Arne Jansen To: chris.mason@oracle.com, linux-btrfs@vger.kernel.org Cc: idryomov@gmail.com Subject: [PATCH] btrfs scrub: extent_map reference not freed Date: Thu, 17 Mar 2011 19:56:00 +0100 Message-Id: <1300388160-10892-1-git-send-email-sensille@gmx.net> X-Mailer: git-send-email 1.7.3.4 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]); Thu, 17 Mar 2011 18:56:14 +0000 (UTC) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index ef59200..ee7671f 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1111,7 +1111,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev, struct map_lookup *map; struct extent_map *em; int i; - int ret; + int ret = -EINVAL; read_lock(&map_tree->map_tree.lock); em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1); @@ -1122,19 +1122,22 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev, map = (struct map_lookup *)em->bdev; if (em->start != chunk_offset) - return -EINVAL; + goto out; if (em->len < length) - return -EINVAL; + goto out; for (i = 0; i < map->num_stripes; ++i) { if (map->stripes[i].dev == sdev->dev) { ret = scrub_stripe(sdev, map, i, chunk_offset, length); if (ret) - return ret; + goto out; } } - return 0; +out: + free_extent_map(em); + + return ret; } static noinline_for_stack