summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-03-14 17:09:11 +0100
committerLubomir Rintel <lkundrak@v3.sk>2016-03-15 09:00:03 +0100
commit4e0968182c7a23404d0f480c32f5c90865177163 (patch)
treeaf116b7c0b29f2dda53e76a3f98a1734c55a15ef
parentff97494e78e9bc39f0b2ee7bfc7bfd6b9bde95c7 (diff)
downloadNetworkManager-4e0968182c7a23404d0f480c32f5c90865177163.tar.gz
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.
-rw-r--r--src/platform/nmp-netns.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/platform/nmp-netns.c b/src/platform/nmp-netns.c
index d7c32b9292..47a8f17971 100644
--- a/src/platform/nmp-netns.c
+++ b/src/platform/nmp-netns.c
@@ -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;
}