ACK: [PATCH 1/2] uefi: esrt: fix the resource leak found by Coverity Scan
Alex Hung
alex.hung at canonical.com
Mon Mar 14 02:49:32 UTC 2016
On 2016-03-08 11:35 AM, Ivan Hu wrote:
> Coverity Scan found:
> *** CID 1352645: Resource leaks (RESOURCE_LEAK)
> /src/uefi/esrt/esrt.c: 45 in esrt_init()
> 39 static int esrt_init(fwts_framework *fw)
> 40 {
> 41 DIR *dir = opendir(FWTS_ESRT_DIR_PATH);
> 42
> 43 if (fwts_firmware_detect() != FWTS_FIRMWARE_UEFI) {
> 44 fwts_log_info(fw, "Cannot detect any UEFI firmware. Aborted.");
>>>> CID 1352645: Resource leaks (RESOURCE_LEAK)
>>>> Variable "dir" going out of scope leaks the storage it points to.
> 45 return FWTS_ABORTED;
> 46 }
> 47
> 48 if (dir) {
> 49 /* Directory exists. */
> 50 closedir(dir);
>
> fix it.
>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> src/uefi/esrt/esrt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/esrt/esrt.c b/src/uefi/esrt/esrt.c
> index 9272c72..7b648c9 100644
> --- a/src/uefi/esrt/esrt.c
> +++ b/src/uefi/esrt/esrt.c
> @@ -38,13 +38,14 @@
>
> static int esrt_init(fwts_framework *fw)
> {
> - DIR *dir = opendir(FWTS_ESRT_DIR_PATH);
>
> if (fwts_firmware_detect() != FWTS_FIRMWARE_UEFI) {
> fwts_log_info(fw, "Cannot detect any UEFI firmware. Aborted.");
> return FWTS_ABORTED;
> }
>
> + DIR *dir = opendir(FWTS_ESRT_DIR_PATH);
> +
> if (dir) {
> /* Directory exists. */
> closedir(dir);
>
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list