From patchwork Thu Mar 29 07:53:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10314663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B06260212 for ; Thu, 29 Mar 2018 07:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 702252A176 for ; Thu, 29 Mar 2018 07:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64CB52A1D4; Thu, 29 Mar 2018 07:54:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5181B2A1D6 for ; Thu, 29 Mar 2018 07:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbeC2HyQ (ORCPT ); Thu, 29 Mar 2018 03:54:16 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:42957 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbeC2HyF (ORCPT ); Thu, 29 Mar 2018 03:54:05 -0400 Received: by mail-pf0-f194.google.com with SMTP id a16so2704942pfn.9 for ; Thu, 29 Mar 2018 00:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=qNKdEtQATBYcglVeYwsqgnNkuXD6xOMnbNW0W5JqaDk=; b=IphGfrJ3UushR6WesxtqAhZe9pHwUAtDk9UYFr+UjYTLnnP3NauKBGKEOrkXxxZ1Sy Vso0rFEyeMcpywmscyyEpJ3UmDBEZ7gIWaIF8P1IcEYYk/oqkQmpg7zMO1dEnf3nx1g8 PouFphbHqJfRGaglc7azTglv7LiDLkO/gMfTLlMVhRTTMZHCBbiZ007Ou8xBV0WU6fY2 e4K6xJwL9n/MYfQwYPISqjaxCIv4HR7ZF9iM3ed1P3LbJkCjyYWtFNslslTH8G+PFfaS r1evCZ8rHIoXbjmKjK+7ll5uHxiYD2DtjFGUZRPPU8Ml6+B8aV26dDXOU5FYXHxmKkfc ZUXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=qNKdEtQATBYcglVeYwsqgnNkuXD6xOMnbNW0W5JqaDk=; b=QqYmKScMhDooZu4mM8CDT1EtN3lhAn/7woGTx3MLmdoB8N0L2vGgZtS5BRS38yFCNb fd1nbXnoiPgDgfOJhmun9/otJtCGM8tdk4DebYY43GNHNv2OiaBqIIwIHty5hEeeuUkT Hws4k39NpQZI4kV3f9zH9huFzgoc0oHOoeVHkPWce0yoTEILVWhCkwrQ6J1bz44IlUEc Qdddh2nP0fzqLqEuW8URluo61ZWOaHRbngY5EQGrAR6OGmUbOjFhCGIVq0bFuvUE/U6i wmIYwPYdp/xvss0XZRQWUjRyqVsBqet2utnRpumxW2rD7aZKXoSb/B37kVwCj0tN+kjW impQ== X-Gm-Message-State: AElRT7EE7qJ4agn9h3envHXpM5pW7fV9Saq0jPRZkE+B7YXusI971fJ3 536mWq5m9lgOI8w0pz+iKCtocOCVEmo= X-Google-Smtp-Source: AIpwx4/gOVLbesWOPFA4EOQzUvKz1k9YU7YeGULnLP4hrC1pYfDUgG01E2tFzCX2Y5An4hx+OfzEXA== X-Received: by 10.98.68.86 with SMTP id r83mr5548589pfa.145.1522310044769; Thu, 29 Mar 2018 00:54:04 -0700 (PDT) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id j65sm9763790pge.58.2018.03.29.00.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 00:54:04 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 2/5] libbtrfsutil: fix memory leak in deleted_subvolumes() Date: Thu, 29 Mar 2018 00:53:54 -0700 Message-Id: <831bd21e3be1653930c5d4b1a3c442d4e96a3b68.1522309741.git.osandov@fb.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval If we fail to reallocate the ID array, we still need to free it. Signed-off-by: Omar Sandoval --- libbtrfsutil/subvolume.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libbtrfsutil/subvolume.c b/libbtrfsutil/subvolume.c index d6c0ced8..867b3e10 100644 --- a/libbtrfsutil/subvolume.c +++ b/libbtrfsutil/subvolume.c @@ -1353,8 +1353,10 @@ PUBLIC enum btrfs_util_error btrfs_util_deleted_subvolumes_fd(int fd, new_capacity = capacity ? capacity * 2 : 1; new_ids = reallocarray(*ids, new_capacity, sizeof(**ids)); - if (!new_ids) - return BTRFS_UTIL_ERROR_NO_MEMORY; + if (!new_ids) { + err = BTRFS_UTIL_ERROR_NO_MEMORY; + goto out; + } *ids = new_ids; capacity = new_capacity;