]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: env: Fix missing closedir in ubi_get_volnum_by_name
authorMiaoqian Lin <linmq006@gmail.com>
Mon, 19 Sep 2022 04:28:09 +0000 (08:28 +0400)
committerTom Rini <trini@konsulko.com>
Thu, 29 Sep 2022 14:10:39 +0000 (10:10 -0400)
The function calls opendir() but missing the corresponding
closedir() before exit the function.
Add missing closedir() to fix it.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
tools/env/fw_env.c

index 908a162202d55d189a57877d610af87f3b108da5..c251e2e6ba7d1b3513a9b162c44c59953957a6a2 100644 (file)
@@ -192,10 +192,13 @@ static int ubi_get_volnum_by_name(int devnum, const char *volname)
                             &tmp_devnum, &volnum);
                if (ret == 2 && devnum == tmp_devnum) {
                        if (ubi_check_volume_sysfs_name(dirent->d_name,
-                                                       volname) == 0)
+                                                       volname) == 0) {
+                               closedir(sysfs_ubi);
                                return volnum;
+                       }
                }
        }
+       closedir(sysfs_ubi);
 
        return -1;
 }