]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Build.c fix coverity issues
authorNigel Croxon <ncroxon@redhat.com>
Tue, 2 Jul 2024 13:49:13 +0000 (09:49 -0400)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Wed, 3 Jul 2024 10:56:08 +0000 (12:56 +0200)
Event leaked_handle: Handle variable "bitmap_fd" going out of
scope leaks the handle.

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Build.c

diff --git a/Build.c b/Build.c
index 1be90e418ad1f1e6d9890e19c94a15cac93d24f7..052b1bc25877e64f9fdf89ab25625d0273100282 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -168,13 +168,13 @@ int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s,
                                goto abort;
                        }
                }
-               if (bitmap_fd >= 0) {
-                       if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
-                               pr_err("Cannot set bitmap file for %s: %s\n", chosen_name,
-                                      strerror(errno));
-                               goto abort;
-                       }
+               if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
+                       pr_err("Cannot set bitmap file for %s: %s\n", chosen_name,
+                              strerror(errno));
+                       close(bitmap_fd);
+                       goto abort;
                }
+       close(bitmap_fd);
        }
        if (ioctl(mdfd, RUN_ARRAY, &param)) {
                pr_err("RUN_ARRAY failed: %s\n", strerror(errno));