Message ID | 20210514080010.9278-1-ivan.hu@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | uefirtvariable: fix memory leak | expand |
On 14/05/2021 09:00, Ivan Hu wrote: > Also add void for the ioctl which is intentional ignore return for > deleting variable. > > Signed-off-by: Ivan Hu <ivan.hu@canonical.com> > --- > src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c > index b756ac96..f5aaa5fb 100644 > --- a/src/uefi/uefirtvariable/uefirtvariable.c > +++ b/src/uefi/uefirtvariable/uefirtvariable.c > @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw) > /* delete the variable which was set */ > setvariable.DataSize = 0; > status = ~0ULL; > - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > > variablename = malloc(sizeof(uint16_t) * variablenamesize); > if (!variablename) { > @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw) > } else > fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test."); > > + if (variablename) > + free(variablename); > + > return FWTS_OK; > } > > Thanks Ivan. Acked-by: Colin Ian King <colin.king@canonical.com>
On 14/05/2021 09:07, Colin Ian King wrote: > On 14/05/2021 09:00, Ivan Hu wrote: >> Also add void for the ioctl which is intentional ignore return for >> deleting variable. >> >> Signed-off-by: Ivan Hu <ivan.hu@canonical.com> >> --- >> src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c >> index b756ac96..f5aaa5fb 100644 >> --- a/src/uefi/uefirtvariable/uefirtvariable.c >> +++ b/src/uefi/uefirtvariable/uefirtvariable.c >> @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw) >> /* delete the variable which was set */ >> setvariable.DataSize = 0; >> status = ~0ULL; >> - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); >> + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); >> >> variablename = malloc(sizeof(uint16_t) * variablenamesize); >> if (!variablename) { >> @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw) >> } else >> fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test."); >> >> + if (variablename) >> + free(variablename); Actually free of a NULL variablename is OK,so the if () is not strictly required, but lets leave that in as it shows intent. >> + >> return FWTS_OK; >> } >> >> > > Thanks Ivan. > > Acked-by: Colin Ian King <colin.king@canonical.com> >
On 2021-05-14 2:00 a.m., Ivan Hu wrote: > Also add void for the ioctl which is intentional ignore return for > deleting variable. > > Signed-off-by: Ivan Hu <ivan.hu@canonical.com> > --- > src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c > index b756ac96..f5aaa5fb 100644 > --- a/src/uefi/uefirtvariable/uefirtvariable.c > +++ b/src/uefi/uefirtvariable/uefirtvariable.c > @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw) > /* delete the variable which was set */ > setvariable.DataSize = 0; > status = ~0ULL; > - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > > variablename = malloc(sizeof(uint16_t) * variablenamesize); > if (!variablename) { > @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw) > } else > fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test."); > > + if (variablename) > + free(variablename); > + > return FWTS_OK; > } > > Acked-by: Alex Hung <alex.hung@canonical.cmo>
diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index b756ac96..f5aaa5fb 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -2223,7 +2223,7 @@ static int uefirtvariable_test9(fwts_framework *fw) /* delete the variable which was set */ setvariable.DataSize = 0; status = ~0ULL; - ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); + (void)ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); variablename = malloc(sizeof(uint16_t) * variablenamesize); if (!variablename) { @@ -2300,6 +2300,9 @@ static int uefirtvariable_test9(fwts_framework *fw) } else fwts_skipped(fw, "QueryVarInfo runtime service supported, skip test."); + if (variablename) + free(variablename); + return FWTS_OK; }
Also add void for the ioctl which is intentional ignore return for deleting variable. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> --- src/uefi/uefirtvariable/uefirtvariable.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)