From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5F5E2116E9; Wed, 7 May 2025 18:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746644115; cv=none; b=CeKh/hU2t0Kd76qOG1UuJGQurBII+JWFfy9yRN/cqDgUd94Ey1fnI7ktvrJKbimPYvjgK8gZkxCuOUJw0GP/l0OSMOE7ti7ih7xjZew/TR2SukZ/xYITs/cAZpDv1rgAybM/EUAoz6+taxJD+YTXo1oAdZzc4iKGom5rO86h6QQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746644115; c=relaxed/simple; bh=7bxA3WOPhBDEFmlGCLkhWXaJnks55k0bReSAOSxMcvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ydk2RN6snGl+nb8O4ldT+kpAly4O/u42gW2J+cx1V1CKO1Eie1cI6MtQvrBitO9N0nwKlfpAOl2EZB7QrZwM+agyX1uwlCen3PZLGniIjZwQwO3T6OJrF/f+et/TQcjr1mtOkckyrs6lBQRvYSm5VcIT2uHbrY+AWDua7imVw7E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yVN39MPQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yVN39MPQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56D3DC4CEE2; Wed, 7 May 2025 18:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746644115; bh=7bxA3WOPhBDEFmlGCLkhWXaJnks55k0bReSAOSxMcvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yVN39MPQLB5UpEtDkXEn9yLRxMdmHo4XBhvRtrF7+Thuvnn8ExfO5ie6wUyqesBBQ 56j7dZP+nb/1bHNy3g7TaAy9+nIslvwpHrRd4cFg5i0dKTTgAnQ+8mYNiZYTDcGHe0 NhdAV0dmHoUqVqY8crjceJFqjBNgb8ZdoCa496v8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Chan , Kalesh AP , Shruti Parab , "David S. Miller" , Sasha Levin Subject: [PATCH 6.14 125/183] bnxt_en: Fix coredump logic to free allocated buffer Date: Wed, 7 May 2025 20:39:30 +0200 Message-ID: <20250507183829.881823369@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250507183824.682671926@linuxfoundation.org> References: <20250507183824.682671926@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shruti Parab [ Upstream commit ea9376cf68230e05492f22ca45d329f16e262c7b ] When handling HWRM_DBG_COREDUMP_LIST FW command in bnxt_hwrm_dbg_dma_data(), the allocated buffer info->dest_buf is not freed in the error path. In the normal path, info->dest_buf is assigned to coredump->data and it will eventually be freed after the coredump is collected. Free info->dest_buf immediately inside bnxt_hwrm_dbg_dma_data() in the error path. Fixes: c74751f4c392 ("bnxt_en: Return error if FW returns more data than dump length") Reported-by: Michael Chan Reviewed-by: Kalesh AP Signed-off-by: Shruti Parab Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c index 7236d8e548ab5..0c0d833d19342 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c @@ -116,6 +116,11 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg, memcpy(info->dest_buf + off, dma_buf, len); } else { rc = -ENOBUFS; + if (cmn_req->req_type == + cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) { + kfree(info->dest_buf); + info->dest_buf = NULL; + } break; } } -- 2.39.5