hotplug: fix a memory leak in handle_button_complete()
authorAlexander Couzens <lynxis@fe80.eu>
Sun, 11 Jun 2017 09:52:47 +0000 (11:52 +0200)
committerAlexander Couzens <lynxis@fe80.eu>
Sun, 11 Jun 2017 11:49:08 +0000 (13:49 +0200)
Found-by: Coverity Scan #1412460
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
plug/hotplug.c

index c8bea1b75b958284968fd6663a8fcb0c9a9fab2a..ce29ced149cb245d9a0d94eb315461b962229364 100644 (file)
@@ -431,8 +431,11 @@ static void handle_button_complete(struct blob_attr *msg, struct blob_attr *data
        if (!timeout)
                return;
 
+       if (!name)
+               return;
+
        b = malloc(sizeof(*b));
-       if (!b || !name)
+       if (!b)
                return;
 
        memset(b, 0, sizeof(*b));