diff mbox series

opal: fix the resource leak for process_dimm and process_mba

Message ID 20240318084813.113005-1-ivan.hu@canonical.com
State Accepted
Headers show
Series opal: fix the resource leak for process_dimm and process_mba | expand

Commit Message

ivanhu March 18, 2024, 8:48 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2058206

fix resource leak found by coverity,
CID 323922: (#1 of 1): Resource leak (RESOURCE_LEAK)
28. leaked_storage: Variable my_buffer going out of scope
leaks the storage it points to.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/opal/mem_info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c
index 0e7e14d4..54f96392 100644
--- a/src/opal/mem_info.c
+++ b/src/opal/mem_info.c
@@ -223,9 +223,9 @@  static int process_dimm(
 				}
 			}
 			free(my_path);
-			free(my_buffer);
 			free(namelist[i]);
 		}
+		free(my_buffer);
 	}
 	free(namelist);
 
@@ -310,9 +310,9 @@  static int process_mba(
 				failures++;
 			}
 			free(my_path);
-			free(my_buffer);
 			free(namelist[i]);
 		}
+		free(my_buffer);
 	}
 	free(namelist);