Commit 6dc445c
daiyanlong
ibdiag_sa: Fix memory leak in sa_query()
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 <[email protected]>1 parent ca4e1c1 commit 6dc445c
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| |||
0 commit comments