Skip to content

ibdiag_sa: Fix memory leak in sa_query() #1602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

YanLongDai
Copy link

When realloc() fails on line 142 of infiniband-diags/ibdiag_sta. c, it will cause the loss of the umad's original memory reference, resulting in a leak of the original memory.

The modified logic is to store the result in a temporary variable new_umad before calling realloc, which can avoid directly overwriting the original pointer umad and prevent losing the reference to the original memory when realloc fails.

When realloc() fails on line 142 of infiniband-diags/ibdiag_sta. c, it will cause the loss of the umad's original memory reference, resulting in a leak of the original memory.

The modified logic is to store the result in a temporary variable new_umad before calling realloc, which can avoid directly overwriting the original pointer umad and prevent losing the reference to the original memory when realloc fails.

Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
@rleon rleon merged commit b837a74 into linux-rdma:master Apr 27, 2025
14 checks passed
@YanLongDai YanLongDai deleted the ibdiag_sa_realloc branch April 27, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants