[Bug 295637] mlx4ib: Fix EQ resource leak on mlx4_ib_add() error path

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 27 May 2026 09:24:10 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295637

            Bug ID: 295637
           Summary: mlx4ib: Fix EQ resource leak on mlx4_ib_add() error
                    path
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: lihaoxiang@isrc.iscas.ac.cn

Created attachment 271232
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=271232&action=edit
possible patch

mlx4_ib_alloc_eqs() allocates ibdev->eq_table and calls mlx4_assign_eq().
mlx4_assign_eq() increments the selected EQ ref_count. The normal remove path
releases these resources through mlx4_ib_free_eqs(), but the mlx4_ib_add()
error paths after mlx4_ib_alloc_eqs() currently fall through to err_map without
calling mlx4_ib_free_eqs().

This can leak ibdev->eq_table and leave EQ references unreleased when any later
initialization step fails. The attached patch fixes the error path by calling
mlx4_ib_free_eqs() at err_map before iounmap(ibdev->uar_map).

-- 
You are receiving this mail because:
You are the assignee for the bug.