Bug 254690 - ocs_fc: fix memory leak bug in ocs_scsi_io_alloc()
Summary: ocs_fc: fix memory leak bug in ocs_scsi_io_alloc()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-01 06:48 UTC by Xiyu Yang
Modified: 2021-12-17 10:37 UTC (History)
2 users (show)

See Also:


Attachments
patch (439 bytes, patch)
2021-04-01 06:48 UTC, Xiyu Yang
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xiyu Yang 2021-04-01 06:48:27 UTC
Created attachment 223742 [details]
patch

The memory leak issue happens in one error handling path of ocs_scsi_io_alloc(). When `io->hio != NULL`, the function forgets to release the "io" allocated by ocs_io_alloc(), causing a memory leak. 

Fix this issue by calling ocs_io_free() when `io->hio != NULL`. The attached patch is generated using Git on the latest version of FreeBSD.
Comment 1 Ram Kishore Vegesna freebsd_committer freebsd_triage 2021-04-14 06:23:30 UTC
Thanks for the patch. The patch looks good.
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-04-22 12:23:58 UTC
A commit in branch main references this bug:

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

commit fc620f9782d1fda5a243fd51a93a0fb46bc80f64
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2021-04-19 15:40:59 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2021-04-22 12:18:37 +0000

    ocs_fc: Fix memory leak in ocs_scsi_io_alloc()

    PR: 254690
    Approved by: mav(mentor)
    MFC after: 2 weeks

 sys/dev/ocs_fc/ocs_scsi.c | 1 +
 1 file changed, 1 insertion(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-12-17 10:04:45 UTC
A commit in branch stable/12 references this bug:

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

commit 12e6cbd158530259d951e3e246a52ddc57fa644b
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2021-04-19 15:40:59 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2021-12-17 09:45:59 +0000

    ocs_fc: Fix memory leak in ocs_scsi_io_alloc()

    PR: 254690
    Approved by: mav(mentor)
    MFC after: 2 weeks

    (cherry picked from commit fc620f9782d1fda5a243fd51a93a0fb46bc80f64)

 sys/dev/ocs_fc/ocs_scsi.c | 1 +
 1 file changed, 1 insertion(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-12-17 10:37:52 UTC
A commit in branch stable/13 references this bug:

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

commit 92d579a9ae192605fe820ff64a6f889e2014e245
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2021-04-19 15:40:59 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2021-12-17 10:11:49 +0000

    ocs_fc: Fix memory leak in ocs_scsi_io_alloc()

    PR: 254690
    Approved by: mav(mentor)
    MFC after: 2 weeks

    (cherry picked from commit fc620f9782d1fda5a243fd51a93a0fb46bc80f64)

 sys/dev/ocs_fc/ocs_scsi.c | 1 +
 1 file changed, 1 insertion(+)