From: Jason Gunthorpe <jgg@xxxxxxxxxx> commit c1eb2512596fb3542357bb6c34c286f5e0374538 upstream. The below commit lifted the locking out of this function but left this error path unlock behind resulting in unbalanced locking. Remove the missed unlock too. Cc: stable@xxxxxxxxxxxxxxx Fixes: 627122280c87 ("RDMA/mlx5: Add work to remove temporary entries from the cache") Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Reviewed-by: Michael Guralnik <michaelgur@xxxxxxxxxx> Link: https://lore.kernel.org/r/78090c210c750f47219b95248f9f782f34548bb1.1716900410.git.leon@xxxxxxxxxx Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/infiniband/hw/mlx5/mr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -641,10 +641,8 @@ static int mlx5_cache_ent_insert(struct new = &((*new)->rb_left); if (cmp < 0) new = &((*new)->rb_right); - if (cmp == 0) { - mutex_unlock(&cache->rb_lock); + if (cmp == 0) return -EEXIST; - } } /* Add new node and rebalance tree. */ Patches currently in stable-queue which might be from jgg@xxxxxxxxxx are queue-6.9/rdma-mlx5-ensure-created-mkeys-always-have-a-populated-rb_key.patch queue-6.9/vfio-pci-collect-hot-reset-devices-to-local-buffer.patch queue-6.9/rdma-mlx5-follow-rb_key.ats-when-creating-new-mkeys.patch queue-6.9/rdma-rxe-fix-data-copy-for-ib_send_inline.patch queue-6.9/rdma-mlx5-remove-extra-unlock-on-error-path.patch