From: Michal Privoznik Date: Mon, 30 Mar 2020 08:56:46 +0000 (+0200) Subject: virSecurityDeviceLabelDefNew: Avoid NULL dereference X-Git-Tag: v6.2.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c8753fe2fb3d7083e8cd1858765996c7bec6185;p=thirdparty%2Flibvirt.git virSecurityDeviceLabelDefNew: Avoid NULL dereference 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 Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c index a2b5ebf6b7..2141d84210 100644 --- a/src/util/virseclabel.c +++ b/src/util/virseclabel.c @@ -77,7 +77,7 @@ virSecurityDeviceLabelDefNew(const char *model) if (VIR_ALLOC(seclabel) < 0) { virSecurityDeviceLabelDefFree(seclabel); - seclabel = NULL; + return NULL; } seclabel->model = g_strdup(model);