]> xenbits.xensource.com Git - libvirt.git/commitdiff
virSecurityDeviceLabelDefNew: Avoid NULL dereference
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 30 Mar 2020 08:56:46 +0000 (10:56 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 30 Mar 2020 14:14:23 +0000 (16:14 +0200)
While it is impossible for VIR_ALLOC() to return an error, we
should be consistent with the rest of the code and not continue
initializing the virSecurityDeviceLabelDef structure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virseclabel.c

index a2b5ebf6b7eaa473f93486e95d8888c143d2aabf..2141d84210443056da4960cea3022d74331ca639 100644 (file)
@@ -77,7 +77,7 @@ virSecurityDeviceLabelDefNew(const char *model)
 
     if (VIR_ALLOC(seclabel) < 0) {
         virSecurityDeviceLabelDefFree(seclabel);
-        seclabel = NULL;
+        return NULL;
     }
 
     seclabel->model = g_strdup(model);