nmp-netns: fix error handling

GError is not used, the error branch would always result in NULL dereference.

Also, check for the result being zero for clarity -- it's the only allowed
success indication.

CID 75365 (#3 of 3): Explicit null dereferenced (FORWARD_NULL)
12. var_deref_op: Dereferencing null pointer error.
This commit is contained in:
Lubomir Rintel
2016-03-14 17:09:11 +01:00
parent ff97494e78
commit 4e0968182c

View File

@@ -318,18 +318,21 @@ nmp_netns_new (void)
return NULL;
}
if (mount ("", "/", "none", MS_SLAVE | MS_REC, NULL)) {
_LOGE (NULL, "failed mount --make-rslave: %s", error->message);
if (mount ("", "/", "none", MS_SLAVE | MS_REC, NULL) != 0) {
errsv = errno;
_LOGE (NULL, "failed mount --make-rslave: %s", g_strerror (errsv));
goto err_out;
}
if (umount2 ("/sys", MNT_DETACH) < 0) {
_LOGE (NULL, "failed umount /sys: %s", error->message);
if (umount2 ("/sys", MNT_DETACH) != 0) {
errsv = errno;
_LOGE (NULL, "failed umount /sys: %s", g_strerror (errsv));
goto err_out;
}
if (mount ("sysfs", "/sys", "sysfs", 0, NULL) < 0) {
_LOGE (NULL, "failed mount /sys: %s", error->message);
if (mount ("sysfs", "/sys", "sysfs", 0, NULL) != 0) {
errsv = errno;
_LOGE (NULL, "failed mount /sys: %s", g_strerror (errsv));
goto err_out;
}