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 81D5B283FC4; Thu, 17 Sep 2026 17:57:46 +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=1789667867; cv=none; b=u8bZGfKB0irGoYIc2a5DPgy68x15YFQlj37rCckKAy+9rG67g8i5HRdmctt60LYaSi0HmivkOgeiGHaPRloQdn/NEyB+lU3plnQroZHoVjDjoDXXc5ugICKP6aXyGtzfTGEU6cGFavenYBeTiFwfmQnBSZmEiCC784AMEUeE3xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789667867; c=relaxed/simple; bh=mITHJWm9QlT7/4wUMYR1iaZ5fdiFOt72f4dMNxdAGjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YXGKFKiEaaR7L9klPCb04QP3+9M60d839B33ZD9hJCbSDbuZmP0CYfQ4plvGMmwoojif10EcV5ckFuGEohstjCnft8RIhWAvMXwsDdNfM4xXWqZF6+UiErCjolodYLEq2qyHGbA4ZA5rPNRqREDTTnwC/8u+jK/5u/Sxc4hXm6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tzSYUdJe; 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="tzSYUdJe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D73A61F000FF; Thu, 17 Sep 2026 17:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789667866; bh=h00jVrjzIbZBKZdkQYqauYCF2rwB6cHyl9aIsHVErds=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tzSYUdJeg62pGvrg7S3a3QtUXTGd6dTKqdLQx14FTDiRIbXW0VFLZDpEcLfhIOtip GYfp6dwwhvj1HkPhDkEeI8jqf6LNIYIzBnehC+oaXSYz7JUD30ctOtrENfxdW1UYPo HB2cACRPKQfy4DVzTTzHdBtL7ARlcGjSZh3ccHzc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li RongQing , Jason Gunthorpe , Sasha Levin Subject: [PATCH 6.12 0235/1102] RDMA/mlx5: Fix state and counter desync on loopback enable failure Date: Thu, 17 Sep 2026 16:02:58 +0100 Message-ID: <20260917151545.486152996@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li RongQing [ Upstream commit 0d32eabccbe4b2f8d45be3192c5f3c76c8af703d ] In mlx5_ib_enable_lb(), dev->lb.enabled was unconditionally set to true even if mlx5_nic_vport_update_local_lb() failed. Fix this by only setting dev->lb.enabled on success. On failure, roll back the reference counters and return the error. Link: https://patch.msgid.link/r/20260601095818.2227-1-lirongqing@baidu.com Signed-off-by: Li RongQing Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index a0b3086381951..2d1cb516d8450 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1869,6 +1869,9 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp) dev->lb.qps == 1) { if (!dev->lb.enabled) { err = mlx5_nic_vport_update_local_lb(dev->mdev, true); + if (err) + goto err_rollback; + dev->lb.enabled = true; } } @@ -1876,6 +1879,14 @@ int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp) mutex_unlock(&dev->lb.mutex); return err; + +err_rollback: + if (td) + dev->lb.user_td--; + if (qp) + dev->lb.qps--; + mutex_unlock(&dev->lb.mutex); + return err; } void mlx5_ib_disable_lb(struct mlx5_ib_dev *dev, bool td, bool qp) -- 2.53.0