Bug 264056

Summary: mlx4(4) Fix resource leak in mlx4_opreq_action()
Product: Base System Reporter: ruc_gongyuanjun
Component: kernAssignee: Hans Petter Selasky <hselasky>
Status: Closed FIXED    
Severity: Affects Many People CC: emaste, hselasky, net, secteam
Priority: --- Keywords: needs-qa
Version: UnspecifiedFlags: koobs: maintainer-feedback? (secteam)
koobs: mfc-stable13?
koobs: mfc-stable12?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
a possible patch none

Description ruc_gongyuanjun 2022-05-18 03:04:50 UTC
Created attachment 234009 [details]
a possible patch

mailbox allocate by mlx4_alloc_cmd_mailbox(dev) should be released
before return.
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2022-05-18 15:42:58 UTC
Have you checked if a similar fix exists for Linux?

--HPS
Comment 2 ruc_gongyuanjun 2022-05-19 07:32:59 UTC
(In reply to Hans Petter Selasky from comment #1)
Hi, the similar bug has been fixed in linux.
Comment 3 Hans Petter Selasky freebsd_committer freebsd_triage 2022-05-19 08:26:47 UTC
Thank you!
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-05-19 08:27:30 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=527762b2f776381569bd662ce236d2845234c0a7

commit 527762b2f776381569bd662ce236d2845234c0a7
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-19 08:10:48 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-05-19 08:13:06 +0000

    mlx4: Fix a memory leak bug.

    In function mlx4_opreq_action(), pointer "mailbox" is not released,
    when mlx4_cmd_box() return and error, causing a memory leak bug.
    Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can
    free this pointer.

    Linux commit:
    febfd9d3c7f74063e8e630b15413ca91b567f963

    PR:             264056
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking

 sys/dev/mlx4/mlx4_core/mlx4_fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-06-07 06:45:49 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=267e6442d049939cd9c8ab5e3b0134deace39e66

commit 267e6442d049939cd9c8ab5e3b0134deace39e66
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-19 08:10:48 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 06:44:28 +0000

    mlx4: Fix a memory leak bug.

    In function mlx4_opreq_action(), pointer "mailbox" is not released,
    when mlx4_cmd_box() return and error, causing a memory leak bug.
    Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can
    free this pointer.

    Linux commit:
    febfd9d3c7f74063e8e630b15413ca91b567f963

    PR:             264056
    Sponsored by:   NVIDIA Networking

    (cherry picked from commit 527762b2f776381569bd662ce236d2845234c0a7)

 sys/dev/mlx4/mlx4_core/mlx4_fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-06-07 06:48:54 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=936bd793479e274155fa2c42e770d0e4e35943cc

commit 936bd793479e274155fa2c42e770d0e4e35943cc
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-19 08:10:48 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 06:46:14 +0000

    mlx4: Fix a memory leak bug.

    In function mlx4_opreq_action(), pointer "mailbox" is not released,
    when mlx4_cmd_box() return and error, causing a memory leak bug.
    Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can
    free this pointer.

    Linux commit:
    febfd9d3c7f74063e8e630b15413ca91b567f963

    PR:             264056
    Sponsored by:   NVIDIA Networking

    (cherry picked from commit 527762b2f776381569bd662ce236d2845234c0a7)

 sys/dev/mlx4/mlx4_core/mlx4_fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)