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.
Created attachment 231293 [details] A simple fix for this bug
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(+)
Hi Zhou, Thanks for reporting and fixing the issue. -Ram
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(+)
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(+)