Bug 261453 - Fix a possible Null pointer dereference in ocs_hw_get_profile_list_cb()
Summary: Fix a possible Null pointer dereference in ocs_hw_get_profile_list_cb()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-25 04:06 UTC by Zhou Qingyang
Modified: 2022-02-14 07:20 UTC (History)
2 users (show)

See Also:


Attachments
A simple fix for this bug (1.19 KB, patch)
2022-01-25 04:08 UTC, Zhou Qingyang
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhou Qingyang 2022-01-25 04:06:52 UTC
In ocs_hw_get_profile_list_cb(), ocs_malloc() is assigned to list and has a dereference after that, which could cause null pointer dereference on failure of
allocation.

Fix this bug by adding a check of list.

This bug is found by a static analyzer, please advise.
Comment 1 Zhou Qingyang 2022-01-25 04:08:44 UTC
Created attachment 231293 [details]
A simple fix for this bug
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-02-09 10:55:54 UTC
A commit in branch main references this bug:

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

commit 7bf31432fd03e2a5a815d1cc81de9a7b1ea3d3ca
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2022-02-09 10:14:12 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2022-02-09 10:48:21 +0000

    ocs_fc: Fix a possible Null pointer dereference

    Fix a possible Null pointer dereference in ocs_hw_get_profile_list_cb()

    PR: 261453
    Reported by: lwhsu

    MFC after: 3 days

 sys/dev/ocs_fc/ocs_hw.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 3 Ram Kishore Vegesna freebsd_committer freebsd_triage 2022-02-09 11:13:39 UTC
Hi Zhou,

Thanks for reporting and fixing the issue.

-Ram
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-02-14 07:19:38 UTC
A commit in branch stable/12 references this bug:

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

commit 9199f5e0ba5c20e2f170b549a743a550d9b38ec8
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2022-02-09 10:14:12 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2022-02-14 07:11:11 +0000

    ocs_fc: Fix a possible Null pointer dereference

    Fix a possible Null pointer dereference in ocs_hw_get_profile_list_cb()

    PR: 261453
    Reported by: lwhsu

    MFC after: 3 days

    (cherry picked from commit 7bf31432fd03e2a5a815d1cc81de9a7b1ea3d3ca)

 sys/dev/ocs_fc/ocs_hw.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-02-14 07:20:39 UTC
A commit in branch stable/13 references this bug:

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

commit 2748f68db95e2e921814472f9c1b77ef49b8fde6
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2022-02-09 10:14:12 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2022-02-14 07:12:55 +0000

    ocs_fc: Fix a possible Null pointer dereference

    Fix a possible Null pointer dereference in ocs_hw_get_profile_list_cb()

    PR: 261453
    Reported by: lwhsu

    MFC after: 3 days

    (cherry picked from commit 7bf31432fd03e2a5a815d1cc81de9a7b1ea3d3ca)

 sys/dev/ocs_fc/ocs_hw.c | 5 +++++
 1 file changed, 5 insertions(+)