tree: sanitize free() handling#1038
Merged
igaw merged 1 commit intolinux-nvme:masterfrom Jul 22, 2025
Merged
Conversation
de8ca5a to
845c2c2
Compare
igaw
reviewed
Jul 22, 2025
| _cleanup_free_ char *h = NULL; | ||
| _cleanup_free_ char *scheme = NULL, *authority = NULL; | ||
| _cleanup_free_ char *path = NULL, *h = NULL; | ||
| const char *host; |
igaw
reviewed
Jul 22, 2025
src/nvme/log.c
Outdated
| }; | ||
| _cleanup_free_ char *header = NULL; | ||
| _cleanup_free_ char *message = NULL; | ||
| _cleanup_free_ char *header = NULL, *message = NULL; |
igaw
reviewed
Jul 22, 2025
src/nvme/tree.c
Outdated
| _cleanup_free_ char *nqn = NULL; | ||
| _cleanup_free_ char *hid = NULL; | ||
| _cleanup_free_ char *hnqn = NULL; | ||
| _cleanup_free_ char *nqn = NULL, *hid = NULL, *hnqn = NULL; |
igaw
reviewed
Jul 22, 2025
src/nvme/tree.c
Outdated
| { | ||
| _cleanup_free_ char *hostnqn = NULL; | ||
| _cleanup_free_ char *hostid = NULL; | ||
| _cleanup_free_ char *hostnqn = NULL, *hostid = NULL; |
Collaborator
There was a problem hiding this comment.
another one of code churn, nothign gained, makes the review more harder, makes backporting harder.
Collaborator
|
I'll fix it up myself. |
As per the POSIX manual, free() is NULL-safe i.e. we could call it without first checking whether the respective pointer is non-NULL. So apply that here. Suggested-by: Martin Belanger <martin.belanger@dell.com> Signed-off-by: Martin George <marting@netapp.com>
Collaborator
|
Thanks! |
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.
As per the POSIX manual, free() is NULL-safe i.e. we could call it without first checking whether the respective pointer is non-NULL. So apply that here. And while at it, reorder some of the cleanup_free items in the declaration section.
Suggested-by: Martin Belanger martin.belanger@dell.com