[PATCH] RDMA/efa: Fix possible deadlock

Ethan Tidmore posted 1 patch 3 weeks, 3 days ago
drivers/infiniband/hw/efa/efa_com.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] RDMA/efa: Fix possible deadlock
Posted by Ethan Tidmore 3 weeks, 3 days ago
In the error path for efa_com_alloc_comp_ctx() the lock assigned to
&aq->avail_cmds is not released.

Add release for &aq->avail_cmds in efa_com_alloc_comp_ctx() error path.

Fixes: ef3b06742c8a2 ("RDMA/efa: Fix use of completion ctx after free")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/infiniband/hw/efa/efa_com.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c
index 56caba612139..e97b5f0d7003 100644
--- a/drivers/infiniband/hw/efa/efa_com.c
+++ b/drivers/infiniband/hw/efa/efa_com.c
@@ -629,6 +629,7 @@ int efa_com_cmd_exec(struct efa_com_admin_queue *aq,
 	comp_ctx = efa_com_alloc_comp_ctx(aq);
 	if (!comp_ctx) {
 		clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state);
+		up(&aq->avail_cmds);
 		return -EINVAL;
 	}
 
-- 
2.53.0
Re: [PATCH] RDMA/efa: Fix possible deadlock
Posted by Leon Romanovsky 3 weeks ago
On Fri, 13 Mar 2026 23:57:30 -0500, Ethan Tidmore wrote:
> In the error path for efa_com_alloc_comp_ctx() the lock assigned to
> &aq->avail_cmds is not released.
> 
> Add release for &aq->avail_cmds in efa_com_alloc_comp_ctx() error path.

Applied, thanks!

[1/1] RDMA/efa: Fix possible deadlock
      https://git.kernel.org/rdma/rdma/c/5c241838c6bba6

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>
Re: [PATCH] RDMA/efa: Fix possible deadlock
Posted by Ethan Tidmore 3 weeks, 3 days ago
On Fri Mar 13, 2026 at 11:57 PM CDT, Ethan Tidmore wrote:
> In the error path for efa_com_alloc_comp_ctx() the lock assigned to
> &aq->avail_cmds is not released.
>
> Add release for &aq->avail_cmds in efa_com_alloc_comp_ctx() error path.

Detected by Smatch:
drivers/infiniband/hw/efa/efa_com.c:662 efa_com_cmd_exec() warn:
inconsistent returns '&aq->avail_cmds'

>
> Fixes: ef3b06742c8a2 ("RDMA/efa: Fix use of completion ctx after free")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---

Forgot to add the Smatch warning, if this version is good please add
this to the commit message.

Thanks,

ET