nbft: fix sizeof operand mismatch in pointer array allocations#3469
Open
bellis-ibm wants to merge 1 commit into
Open
nbft: fix sizeof operand mismatch in pointer array allocations#3469bellis-ibm wants to merge 1 commit into
bellis-ibm wants to merge 1 commit into
Conversation
The hfi_list, security_list, discovery_list, and subsystem_ns_list arrays were allocated using sizeof(struct) instead of sizeof(struct *), which caused memory over-allocation and triggered static analysis warnings. These arrays store pointers to structs, not the structs themselves. Changed to use sizeof(struct *) to allocate the correct amount of memory for pointer arrays. Signed-off-by:Brooke Ellis <Brooke.Ellis@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four calloc() calls used sizeof(struct) instead of sizeof(struct *)
when allocating pointer arrays. The hfi_list, security_list,
discovery_list, and subsystem_ns_list objects are declared as
pointer arrays and should be allocated using the pointer type size.
Use sizeof(struct *) to match the array element type and resolve the
static analysis warnings.
Signed-off-by: Brooke Ellis Brooke.Ellis@ibm.com