From patchwork Sun Sep 2 13:44:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1396661 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 01391DF283 for ; Sun, 2 Sep 2012 13:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753502Ab2IBNox (ORCPT ); Sun, 2 Sep 2012 09:44:53 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:57886 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762Ab2IBNow (ORCPT ); Sun, 2 Sep 2012 09:44:52 -0400 Received: by qcro28 with SMTP id o28so2957457qcr.19 for ; Sun, 02 Sep 2012 06:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=Pt0LfXWTbbU2csAwb0N5CJF2KGkR9XpK8L7wB0LyIbM=; b=t4w8eHgfAweh5P8Z0RJTBRhd0A26/2uZWuJn6hL8U81vf72BtCYowZQ0yonLiyXV/3 VuQaXhAlyglE7+8CaGZEcVD/EHx+gaLuMSOff8XBoHn0Ln05l3SJJ5ikju9zfyJQB2mk wmhnDVlOA28sg1Jm3cIbZLVVUravfBJv8AbLIDUnyAHKCFHb6sXRErwMBWAkSBJgAoHB IrjUhBeV86df2iTL9uDTvRhVhI9ObyvrNdVezXrNnPuXjypZttvQAfetlOkHslZXOBeb DB1dH3iX1yoL1dZXfU3EgHh8tW1eD5TDNzbMhQ9udPxG5LDHgh+cXznrUVbydy5svCun cyOQ== MIME-Version: 1.0 Received: by 10.229.106.84 with SMTP id w20mr8278756qco.1.1346593491766; Sun, 02 Sep 2012 06:44:51 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 2 Sep 2012 06:44:51 -0700 (PDT) Date: Sun, 2 Sep 2012 21:44:51 +0800 Message-ID: Subject: [PATCH] Btrfs: fix possible memory leak in scrub_setup_recheck_block() From: Wei Yongjun To: chris.mason@fusionio.com Cc: yongjun_wei@trendmicro.com.cn, linux-btrfs@vger.kernel.org Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Wei Yongjun bbio has been malloced in btrfs_map_block() and should be freed before leaving from the error handling cases. spatch with a semantic match is used to found this problem. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun --- fs/btrfs/scrub.c | 1 + 1 file changed, 1 insertion(+) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index b223620..4e9eafe 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1029,6 +1029,7 @@ static int scrub_setup_recheck_block(struct scrub_dev *sdev, spin_lock(&sdev->stat_lock); sdev->stat.malloc_errors++; spin_unlock(&sdev->stat_lock); + kfree(bbio); return -ENOMEM; } sblock->page_count++;