From patchwork Mon Mar 18 08:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ivanhu X-Patchwork-Id: 1913032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TypRL45WLz1yWy for ; Mon, 18 Mar 2024 19:48:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rm8fO-0006V6-29; Mon, 18 Mar 2024 08:48:22 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rm8fK-0006UH-KY for fwts-devel@lists.ubuntu.com; Mon, 18 Mar 2024 08:48:18 +0000 Received: from canonical.com (unknown [10.101.194.165]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 8A5593F5FC for ; Mon, 18 Mar 2024 08:48:17 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] opal: fix the resource leak for process_dimm and process_mba Date: Mon, 18 Mar 2024 16:48:12 +0800 Message-Id: <20240318084813.113005-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" BugLink: https://bugs.launchpad.net/fwts/+bug/2058206 fix resource leak found by coverity, CID 323922: (#1 of 1): Resource leak (RESOURCE_LEAK) 28. leaked_storage: Variable my_buffer going out of scope leaks the storage it points to. Signed-off-by: Ivan Hu --- src/opal/mem_info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c index 0e7e14d4..54f96392 100644 --- a/src/opal/mem_info.c +++ b/src/opal/mem_info.c @@ -223,9 +223,9 @@ static int process_dimm( } } free(my_path); - free(my_buffer); free(namelist[i]); } + free(my_buffer); } free(namelist); @@ -310,9 +310,9 @@ static int process_mba( failures++; } free(my_path); - free(my_buffer); free(namelist[i]); } + free(my_buffer); } free(namelist);