Skip to content

Commit

Permalink
fabtests/efa: Fix memory leak in efa_info_test
Browse files Browse the repository at this point in the history
fi will become NULL when exiting the loop. The
final fi_freeinfo doesn't do anything. This patch
fixes it by using a staging variable info to iterate
the loop

Signed-off-by: Shi Jin <[email protected]>
  • Loading branch information
shijin-aws committed May 7, 2024
1 parent 94f22a9 commit ee88250
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fabtests/prov/efa/src/efa_info_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
int main(int argc, char **argv)
{
int ret;
struct fi_info *info;

hints = fi_allocinfo();
if (!hints)
return EXIT_FAILURE;
Expand All @@ -52,12 +54,14 @@ int main(int argc, char **argv)
FT_PRINTERR("ft_getinfo", -ret);
goto out;
}
while (NULL != fi) {
if (0 != strcmp(fi->fabric_attr->name, "efa")) {

info = fi;
while (NULL != info) {
if (0 != strcmp(info->fabric_attr->name, "efa")) {
ret = EXIT_FAILURE;
goto out;
}
fi = fi->next;
info = info->next;
}

out:
Expand Down

0 comments on commit ee88250

Please sign in to comment.