Message ID | 20200407174439.922624-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | uefi: uefirtvariable: fix a memory leak of variablename | expand |
On 2020-04-07 11:44 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > In the case where an ioctl fails the error handling currently > returns without freeing variablename. Fix this by setting ret > to FWTS_ERROR and falling through to the return path that > frees variable name and returns the error code. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/uefi/uefirtvariable/uefirtvariable.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c > index 3986d1d3..fb993983 100644 > --- a/src/uefi/uefirtvariable/uefirtvariable.c > +++ b/src/uefi/uefirtvariable/uefirtvariable.c > @@ -466,12 +466,11 @@ err_restore_env: > status = ~0ULL; > > ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > - > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to delete variable with UEFI runtime service."); > fwts_uefi_print_status_info(fw, status); > - return FWTS_ERROR; > + ret = FWTS_ERROR; > } > > if (variablename) > Acked-by: Alex Hung <alex.hung@canonical.com>
On 4/8/20 1:44 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > In the case where an ioctl fails the error handling currently > returns without freeing variablename. Fix this by setting ret > to FWTS_ERROR and falling through to the return path that > frees variable name and returns the error code. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/uefi/uefirtvariable/uefirtvariable.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c > index 3986d1d3..fb993983 100644 > --- a/src/uefi/uefirtvariable/uefirtvariable.c > +++ b/src/uefi/uefirtvariable/uefirtvariable.c > @@ -466,12 +466,11 @@ err_restore_env: > status = ~0ULL; > > ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); > - > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to delete variable with UEFI runtime service."); > fwts_uefi_print_status_info(fw, status); > - return FWTS_ERROR; > + ret = FWTS_ERROR; > } > > if (variablename) > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index 3986d1d3..fb993983 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -466,12 +466,11 @@ err_restore_env: status = ~0ULL; ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable); - if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to delete variable with UEFI runtime service."); fwts_uefi_print_status_info(fw, status); - return FWTS_ERROR; + ret = FWTS_ERROR; } if (variablename)