Message ID | 20210922095016.160051-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | opal: Fix a few memory leaks on asprint allocated buffers | expand |
On 2021-09-22 3:50 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > There are a few paths where asprintf allocated buffers are not > being free'd. Fix the leaks. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/opal/mem_info.c | 4 ++++ > src/opal/mtd_info.c | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c > index 03b04762..a5291e28 100644 > --- a/src/opal/mem_info.c > +++ b/src/opal/mem_info.c > @@ -222,6 +222,7 @@ static int process_dimm( > } > } > > + free(my_path); > free(my_buffer); > free(namelist[i]); > } > @@ -308,6 +309,7 @@ static int process_mba( > if (process_dimm(fw, "dimm", my_path)) { > failures++; > } > + free(my_path); > free(my_buffer); > free(namelist[i]); > } > @@ -363,6 +365,7 @@ static int get_linux_mem_devices(fwts_framework *fw) > > dirent = namelist[i]; > > + mem_buffer = NULL; > if (dirent->d_name[0] == '.' || > asprintf(&mem_buffer, > "%s", > @@ -395,6 +398,7 @@ static int get_linux_mem_devices(fwts_framework *fw) > if (process_mba(fw, "mba", mba_path)) { > failures++; > } > + free(mba_path); > free(mem_buffer); > free(namelist[i]); > } > diff --git a/src/opal/mtd_info.c b/src/opal/mtd_info.c > index 209b2566..4a00fc46 100644 > --- a/src/opal/mtd_info.c > +++ b/src/opal/mtd_info.c > @@ -315,8 +315,8 @@ static int mtd_info_test1(fwts_framework *fw) > } > fwts_log_nl(fw); > } > - free(mtd_device_path); > } > + free(mtd_device_path); > } > > free(namelist[i]); > Acked-by: Alex Hung <alex.hung@canonical.com>
On 9/22/21 5:50 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > There are a few paths where asprintf allocated buffers are not > being free'd. Fix the leaks. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/opal/mem_info.c | 4 ++++ > src/opal/mtd_info.c | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c > index 03b04762..a5291e28 100644 > --- a/src/opal/mem_info.c > +++ b/src/opal/mem_info.c > @@ -222,6 +222,7 @@ static int process_dimm( > } > } > > + free(my_path); > free(my_buffer); > free(namelist[i]); > } > @@ -308,6 +309,7 @@ static int process_mba( > if (process_dimm(fw, "dimm", my_path)) { > failures++; > } > + free(my_path); > free(my_buffer); > free(namelist[i]); > } > @@ -363,6 +365,7 @@ static int get_linux_mem_devices(fwts_framework *fw) > > dirent = namelist[i]; > > + mem_buffer = NULL; > if (dirent->d_name[0] == '.' || > asprintf(&mem_buffer, > "%s", > @@ -395,6 +398,7 @@ static int get_linux_mem_devices(fwts_framework *fw) > if (process_mba(fw, "mba", mba_path)) { > failures++; > } > + free(mba_path); > free(mem_buffer); > free(namelist[i]); > } > diff --git a/src/opal/mtd_info.c b/src/opal/mtd_info.c > index 209b2566..4a00fc46 100644 > --- a/src/opal/mtd_info.c > +++ b/src/opal/mtd_info.c > @@ -315,8 +315,8 @@ static int mtd_info_test1(fwts_framework *fw) > } > fwts_log_nl(fw); > } > - free(mtd_device_path); > } > + free(mtd_device_path); > } > > free(namelist[i]); > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/opal/mem_info.c b/src/opal/mem_info.c index 03b04762..a5291e28 100644 --- a/src/opal/mem_info.c +++ b/src/opal/mem_info.c @@ -222,6 +222,7 @@ static int process_dimm( } } + free(my_path); free(my_buffer); free(namelist[i]); } @@ -308,6 +309,7 @@ static int process_mba( if (process_dimm(fw, "dimm", my_path)) { failures++; } + free(my_path); free(my_buffer); free(namelist[i]); } @@ -363,6 +365,7 @@ static int get_linux_mem_devices(fwts_framework *fw) dirent = namelist[i]; + mem_buffer = NULL; if (dirent->d_name[0] == '.' || asprintf(&mem_buffer, "%s", @@ -395,6 +398,7 @@ static int get_linux_mem_devices(fwts_framework *fw) if (process_mba(fw, "mba", mba_path)) { failures++; } + free(mba_path); free(mem_buffer); free(namelist[i]); } diff --git a/src/opal/mtd_info.c b/src/opal/mtd_info.c index 209b2566..4a00fc46 100644 --- a/src/opal/mtd_info.c +++ b/src/opal/mtd_info.c @@ -315,8 +315,8 @@ static int mtd_info_test1(fwts_framework *fw) } fwts_log_nl(fw); } - free(mtd_device_path); } + free(mtd_device_path); } free(namelist[i]);