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 0086B37E2E0; Mon, 9 Feb 2026 14:39:31 +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=1770647971; cv=none; b=dol+7tiWWzQXLidJ3fgOQtgEYFUUAWDSTlHJAqYxpLJCNUCQ6Fe4Evce+U2+NwHN/KxkAtHU9MkcVqTfqdjc0N54GiYjT3AxANbDFHCdstaBVlv8nw6bMBlsRYcL4x6kR7rhFwjIKPcfj7aQB9EHBA52plm9k6r8udSZoOY4iS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770647971; c=relaxed/simple; bh=UF2P+OXM6YPE+7nvzLzOUxtkCqG+CR0y3gsGXWpROnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tlI4z/UzEphQGR0/jFKvJmHSXhoJ0dzgQIVo1vKKsEN3qUdzUnJctKDR+0t6v0enKj1Egwr9o+LnyDuDsuVCK/HTqWSencOsu7MYJTluvaB1z3t4fJZEL1J4dAQLVzQ4+k2k51m6uUdT1HxTi0fUHkA0RGf+OLK98/vSiXAT/Ps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OqHKYoke; 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="OqHKYoke" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8294CC116C6; Mon, 9 Feb 2026 14:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770647970; bh=UF2P+OXM6YPE+7nvzLzOUxtkCqG+CR0y3gsGXWpROnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OqHKYoke8nVEXiw8FncFnWrUo/4NYlXu2KNSJG80cOVtONcT6d5GIcEI4c82nltZs qqISX4OjkZhYLGFgGngQVNOf3dV0zHYsLyjfaZuEB4OTnC75sFRbv0p7/DU5mHWP39 +zNl+wDMEjKiZOwTlA0DV8TQjrO5KmUoMXsI4Oro= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Horman , Zilin Guan , Kory Maincent , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 082/113] net: liquidio: Fix off-by-one error in PF setup_nic_devices() cleanup Date: Mon, 9 Feb 2026 15:23:51 +0100 Message-ID: <20260209142313.130175172@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142310.204833231@linuxfoundation.org> References: <20260209142310.204833231@linuxfoundation.org> User-Agent: quilt/0.69 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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zilin Guan [ Upstream commit 8558aef4e8a1a83049ab906d21d391093cfa7e7f ] In setup_nic_devices(), the initialization loop jumps to the label setup_nic_dev_free on failure. The current cleanup loop while(i--) skip the failing index i, causing a memory leak. Fix this by changing the loop to iterate from the current index i down to 0. Also, decrement i in the devlink_alloc failure path to point to the last successfully allocated index. Compile tested only. Issue found using code review. Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters") Suggested-by: Simon Horman Signed-off-by: Zilin Guan Reviewed-by: Kory Maincent Link: https://patch.msgid.link/20260128154440.278369-3-zilin@seu.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/cavium/liquidio/lio_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index eba0740782379..ebb82767b6e53 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -3758,6 +3758,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) if (!devlink) { device_unlock(&octeon_dev->pci_dev->dev); dev_err(&octeon_dev->pci_dev->dev, "devlink alloc failed\n"); + i--; goto setup_nic_dev_free; } @@ -3773,11 +3774,11 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) setup_nic_dev_free: - while (i--) { + do { dev_err(&octeon_dev->pci_dev->dev, "NIC ifidx:%d Setup failed\n", i); liquidio_destroy_nic_device(octeon_dev, i); - } + } while (i--); setup_nic_dev_done: -- 2.51.0