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)
Depends on:
Reported: 2021-04-01 06:48 UTC by Xiyu Yang
Modified: 2021-04-23 06:41 UTC (History)
2 users (show)

See Also:

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]

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 2021-04-14 06:23:30 UTC
Thanks for the patch. The patch looks good.
Comment 2 commit-hook freebsd_committer 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(+)