From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8962C3D6664; Fri, 4 Sep 2026 05:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499155; cv=none; b=NLfBDzu8tYl8ViY8YJMONS9hdnvlxQCGNvF8Ax2zgLCxouzl7i8OgJhmaKDsTfM88lAlqGZ9g7DwU272DckZbQtbmfuBNVL9P8vKPd3N3fwKwt+7RE9i1oi+pdcDaazngThFJ6XKGsvNNpdVAvWI2POS63eAvpzHK96vY980krI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499155; c=relaxed/simple; bh=qYJqKGX1m9vsBXvcnARgY5lr8uqYVztGPqGs0gZ+pxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A5tnUG6G0e/lOZTtYl0K7EA9zxZxUoJyWjIxy3ASoFZAQX2j3dw2U6gC654/KViUHpJQuUTLORjMU85lwzBnwP3njj3Z1pfzw6D35lyCDS9MFiGwxLgD6VH9vKK4eAUlgovLua7UiLA1gE1eoaJbASrw+BXTUZyt3cRGBRCP1lI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HzKigOUq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HzKigOUq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E400D1F00A3D; Fri, 4 Sep 2026 05:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788499154; bh=MbYV6u7MX28RgyF9ERtR8+fJZgchJooNKY7D+E8NgO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HzKigOUqzs1iqbSdiM+ImgwUActSiCsfveC3QXNTPbm/d1SaKVYo+VoLeJuGryrfx x7OlXECvMihasLhtt32qcvguMfsEZV5xQB5PddEoFMV9ifYLcAnhV3wVFlbT8gOfvo PcHpmEhdPVXng3p9ccynXUMn7TS6iJG5RCV/Fb/w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiangshan Yi , Simon Horman , Jakub Kicinski Subject: [PATCH 7.2 318/713] bnx2x: fix double free in bnx2x_init_firmware() error path Date: Fri, 4 Sep 2026 06:54:46 +0200 Message-ID: <20260904045810.958620224@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiangshan Yi commit d2796ffe38cb4155afe0eab23636295b096c27a5 upstream. bnx2x_init_firmware() frees bp->init_ops, bp->init_data and bp->init_ops_offsets in its error path without setting them to NULL. The cleanup function bnx2x_release_firmware() frees the same three pointers unconditionally, so if init_firmware fails and release_firmware is later called (e.g. from __bnx2x_remove or through the function state machine), all three are freed a second time. Set each pointer to NULL after kfree() in the error path so that the subsequent kfree(NULL) in bnx2x_release_firmware() is a safe no-op. Fixes: 94a78b79cb5f ("bnx2x: Separated FW from the source.") Cc: stable@vger.kernel.org Signed-off-by: Jiangshan Yi Reviewed-by: Simon Horman Link: https://patch.msgid.link/20260815122149.951215-1-yijiangshan@kylinos.cn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -13473,10 +13473,13 @@ static int bnx2x_init_firmware(struct bn iro_alloc_err: kfree(bp->init_ops_offsets); + bp->init_ops_offsets = NULL; init_offsets_alloc_err: kfree(bp->init_ops); + bp->init_ops = NULL; init_ops_alloc_err: kfree(bp->init_data); + bp->init_data = NULL; request_firmware_exit: release_firmware(bp->firmware); bp->firmware = NULL;