summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-06-17 12:58:09 (GMT)
committerThomas Haller <thaller@redhat.com>2014-06-17 15:33:26 (GMT)
commit8f82270cffb7034bc930a9606bc8e1412d2fa73d (patch)
tree429081ead32bbd5fa2b2fc15b9fa64a2b0527991
parentfeda705426c4a1d24aff9d6a0b7a264df226ae10 (diff)
downloadlibnl-8f82270cffb7034bc930a9606bc8e1412d2fa73d.zip
libnl-8f82270cffb7034bc930a9606bc8e1412d2fa73d.tar.gz
libnl-8f82270cffb7034bc930a9606bc8e1412d2fa73d.tar.bz2
cache_mngr: Return proper error code if nl_socket_alloc() fails
If nl_socket_alloc() failes in nl_cache_mngr_alloc() we would currently return 0 due to the previous assignment of the err variable, even though the failed allocation is an error condition. Fix this by setting err to -NLE_NOMEM if nl_socket_alloc() fails. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--lib/cache_mngr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c
index 36f5ca8..e24d44c 100644
--- a/lib/cache_mngr.c
+++ b/lib/cache_mngr.c
@@ -173,8 +173,10 @@ int nl_cache_mngr_alloc(struct nl_sock *sk, int protocol, int flags,
/* Create and allocate socket for sync cache fills */
mngr->cm_sync_sock = nl_socket_alloc();
- if (!mngr->cm_sync_sock)
+ if (!mngr->cm_sync_sock) {
+ err = -NLE_NOMEM;
goto errout;
+ }
if ((err = nl_connect(mngr->cm_sync_sock, protocol)) < 0)
goto errout_free_sync_sock;