From patchwork Wed Apr 3 12:38:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1075894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Z5Kd0HShz9sSk; Wed, 3 Apr 2019 23:41:09 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hBfCO-00025G-DZ; Wed, 03 Apr 2019 12:41:00 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hBfCM-00024w-9i for kernel-team@lists.ubuntu.com; Wed, 03 Apr 2019 12:40:58 +0000 Received: from mail-wr1-f69.google.com ([209.85.221.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hBfCL-0005nZ-VE for kernel-team@lists.ubuntu.com; Wed, 03 Apr 2019 12:40:58 +0000 Received: by mail-wr1-f69.google.com with SMTP id t9so12962543wrs.16 for ; Wed, 03 Apr 2019 05:40:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=znSrwxSAGliqJ1JSUjTnxmJ0Y71x+NmWc0EPrUjQZ70=; b=qyr3ZIz0lidk9pdQr3brz7KV2tbQEoAbehnySS012IsD+mR2+Ktl9IuMUfWB7XxCWh DPjTjMfRONtmTzID1rakiMUVBTszvHxvZ7FzvJZt+VyZUxne/ShQiSft5k0f3PidboXF tU8jMPsmSRsbPhEzGn3Ak5zmp2lNWZCLVYDtfkmaIjjJGIsGW6Kxw77qxjrSyWzGmWqt OhSTMmsZ5B+Ps6L5Ghv7Ps8RwXOHhg3UlicJ/y9QYw5bd9k0EVAkwlSLVXtFWrAbdcbB +0DJePd/uqzy9kAS6dKEnvwEBed8/aMhHG5BSQyB8jGyb8nes3F0RWURpTnukZk5u54H vWWA== X-Gm-Message-State: APjAAAVdGy/QB/CzH5eUIFqr4VZvEqRmU5g/LpG8E10VyZ/kzp5xEbqt U70j+RWvHHm2Ai4gsQbwxkMbsEoT/NQKyHBYHI1JjDsTsPFNq81Tll5t+auCGOfTToqixYdEpLB b+tf22JPiXPu/5V9DckkNpgxkvxsqGL2hEZasx/RneQ== X-Received: by 2002:adf:efc1:: with SMTP id i1mr23633706wrp.199.1554295257507; Wed, 03 Apr 2019 05:40:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8uYwnHv2BxEyt3E/svjBrjxWS0upnQM6P/vBT3h0n0/jMoH/VNTfnWzA/E6BJVUf6Nf4Huw== X-Received: by 2002:adf:efc1:: with SMTP id i1mr23633698wrp.199.1554295257354; Wed, 03 Apr 2019 05:40:57 -0700 (PDT) Received: from localhost.localdomain (host141-127-dynamic.17-87-r.retail.telecomitalia.it. [87.17.127.141]) by smtp.gmail.com with ESMTPSA id v192sm24748132wme.24.2019.04.03.05.40.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 05:40:56 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU] [Xenial] [PATCH 1/1] Btrfs: fix extent map leak during fallocate error path Date: Wed, 3 Apr 2019 14:38:58 +0200 Message-Id: <20190403123857.1420-2-andrea.righi@canonical.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190403123857.1420-1-andrea.righi@canonical.com> References: <20190403123857.1420-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Filipe Manana BugLink: https://bugs.launchpad.net/bugs/1822579 If the call to btrfs_qgroup_reserve_data() failed, we were leaking an extent map structure. The failure can happen either due to an -ENOMEM condition or, when quotas are enabled, due to -EDQUOT for example. Signed-off-by: Filipe Manana Reviewed-by: David Sterba (backported from commit be2d253cc98244765323a7c94cc1ac5cd5a17072) Signed-off-by: Andrea Righi Acked-by: Colin Ian King Acked-by: Thadeu Lima de Souza Cascardo --- fs/btrfs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 751fcc6..743ad5e 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2763,8 +2763,10 @@ static long btrfs_fallocate(struct file *file, int mode, } ret = btrfs_qgroup_reserve_data(inode, cur_offset, last_byte - cur_offset); - if (ret < 0) + if (ret < 0) { + free_extent_map(em); break; + } } free_extent_map(em); cur_offset = last_byte;