Bug 264248 - ib_cm: Fix a resource leak in ib_cm_insert_listen()
Summary: ib_cm: Fix a resource leak in ib_cm_insert_listen()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Hans Petter Selasky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-26 02:53 UTC by ruc_gongyuanjun
Modified: 2022-06-07 06:48 UTC (History)
2 users (show)

See Also:


Attachments
a possible patch (1022 bytes, patch)
2022-05-26 02:53 UTC, ruc_gongyuanjun
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ruc_gongyuanjun 2022-05-26 02:53:24 UTC
Created attachment 234221 [details]
a possible patch

cm_id, which is allocated by ib_create_cm_id, is not freed in
an error path, causing a resource leak.
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2022-05-26 16:06:59 UTC
Have you checked if a fix exist in Linux?
Comment 2 Hans Petter Selasky freebsd_committer freebsd_triage 2022-05-30 18:23:10 UTC
Thank you!

--HPS
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-05-30 18:23:12 UTC
A commit in branch main references this bug:

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

commit c4a415505311e30093b6d9ee0493427a66f2b0de
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-30 18:19:33 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-05-30 18:22:18 +0000

    ibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()

    The algorithm pre-allocates a cm_id since allocation cannot be done while
    holding the cm.lock spinlock, however it doesn't free it on one error
    path, leading to a memory leak.

    Linux commit:
    c14dfddbd869bf0c2bafb7ef260c41d9cebbcfec

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

 sys/ofed/drivers/infiniband/core/ib_cm.c | 1 +
 1 file changed, 1 insertion(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-06-07 06:45:46 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5570397c129d490b909b1962f51376d6742eacf4

commit 5570397c129d490b909b1962f51376d6742eacf4
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-30 18:19:33 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 06:44:29 +0000

    ibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()

    The algorithm pre-allocates a cm_id since allocation cannot be done while
    holding the cm.lock spinlock, however it doesn't free it on one error
    path, leading to a memory leak.

    Linux commit:
    c14dfddbd869bf0c2bafb7ef260c41d9cebbcfec

    PR:             264248
    Sponsored by:   NVIDIA Networking

    (cherry picked from commit c4a415505311e30093b6d9ee0493427a66f2b0de)

 sys/ofed/drivers/infiniband/core/ib_cm.c | 1 +
 1 file changed, 1 insertion(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-06-07 06:48:51 UTC
A commit in branch stable/12 references this bug:

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

commit dad7c072f482527b4964bbd4b067d06c6df2e592
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-30 18:19:33 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 06:46:22 +0000

    ibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()

    The algorithm pre-allocates a cm_id since allocation cannot be done while
    holding the cm.lock spinlock, however it doesn't free it on one error
    path, leading to a memory leak.

    Linux commit:
    c14dfddbd869bf0c2bafb7ef260c41d9cebbcfec

    PR:             264248
    Sponsored by:   NVIDIA Networking

    (cherry picked from commit c4a415505311e30093b6d9ee0493427a66f2b0de)

 sys/ofed/drivers/infiniband/core/ib_cm.c | 1 +
 1 file changed, 1 insertion(+)