From patchwork Thu Jun 29 15:52:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 9817275 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 55A2260365 for ; Thu, 29 Jun 2017 15:53:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05CE42868D for ; Thu, 29 Jun 2017 15:53:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE88128772; Thu, 29 Jun 2017 15:53:00 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 6B5C528770 for ; Thu, 29 Jun 2017 15:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbdF2Pw7 (ORCPT ); Thu, 29 Jun 2017 11:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40088 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbdF2Pw7 (ORCPT ); Thu, 29 Jun 2017 11:52:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68745612B3; Thu, 29 Jun 2017 15:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 68745612B3 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=billodo@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 68745612B3 Received: from localhost.localdomain.com (ovpn-121-88.rdu2.redhat.com [10.10.121.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2A4E5D6A6; Thu, 29 Jun 2017 15:52:57 +0000 (UTC) From: Bill O'Donnell To: linux-xfs@vger.kernel.org Cc: sandeen@sandeen.net Subject: [PATCH] xfs_spaceman: fix potential memory leak by malloc in scan_ag Date: Thu, 29 Jun 2017 10:52:56 -0500 Message-Id: <20170629155256.3607-1-billodo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 29 Jun 2017 15:52:58 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP scan_ag mallocs memory that is potentially leaked. Add a free to alleviate the potential leak. Fixes CoverityScan CID#1413772 (RESOURCE_LEAK) Signed-off-by: Bill O'Donnell Reviewed-by: Darrick J. Wong --- spaceman/freesp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spaceman/freesp.c b/spaceman/freesp.c index 22aec821..367c95d1 100644 --- a/spaceman/freesp.c +++ b/spaceman/freesp.c @@ -239,7 +239,9 @@ scan_ag( printf(_("%10u %10llu %10llu\n"), agno, freeexts, freeblks); } + free(fsmap); } + static void aglistadd( char *a)