Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754933AbdFLQWa (ORCPT ); Mon, 12 Jun 2017 12:22:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41838 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754862AbdFLPhi (ORCPT ); Mon, 12 Jun 2017 11:37:38 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Mahoney , Liu Bo , David Sterba Subject: [PATCH 4.9 086/119] btrfs: fix memory leak in update_space_info failure path Date: Mon, 12 Jun 2017 17:25:48 +0200 Message-Id: <20170612152602.935474259@linuxfoundation.org> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170612152556.601664278@linuxfoundation.org> References: <20170612152556.601664278@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 911 Lines: 32 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Mahoney commit 896533a7da929136d0432713f02a3edffece2826 upstream. If we fail to add the space_info kobject, we'll leak the memory for the percpu counter. Fixes: 6ab0a2029c (btrfs: publish allocation data in sysfs) Signed-off-by: Jeff Mahoney Reviewed-by: Liu Bo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3984,6 +3984,7 @@ static int update_space_info(struct btrf info->space_info_kobj, "%s", alloc_name(found->flags)); if (ret) { + percpu_counter_destroy(&found->total_bytes_pinned); kfree(found); return ret; }