blockd: fix resource leak discovered by coverity scan
authorDaniel Golle <daniel@makrotopia.org>
Thu, 12 Aug 2021 15:34:39 +0000 (16:34 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 14 Aug 2021 17:53:02 +0000 (18:53 +0100)
Fixes Coverity CID 1463265

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
blockd.c

index 3bfdea10313fc59a49cae407e8fbe936078aa55f..365755a537e2a3a9084c346bba356aa243dde183 100644 (file)
--- a/blockd.c
+++ b/blockd.c
@@ -152,6 +152,9 @@ static int hotplug_call_mount(struct ubus_context *ctx, const char *action,
        pid = fork();
        switch (pid) {
        case -1:
+               if (c)
+                       free(c);
+
                err = -errno;
                ULOG_ERR("fork() failed\n");
                return err;