projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bb99e80
)
system-linux: fix memory leak on error in system_if_check
author
Felix Fietkau
<nbd@openwrt.org>
Thu, 29 Oct 2015 15:06:12 +0000
(16:06 +0100)
committer
Felix Fietkau
<nbd@openwrt.org>
Thu, 29 Oct 2015 15:06:13 +0000
(16:06 +0100)
Detected by Coverity CID
1330302
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
system-linux.c
patch
|
blob
|
history
diff --git
a/system-linux.c
b/system-linux.c
index
27c0f1e
..
611acb8
100644
(file)
--- a/
system-linux.c
+++ b/
system-linux.c
@@
-1295,10
+1295,13
@@
int system_if_check(struct device *dev)
int ret = 1;
msg = nlmsg_alloc_simple(RTM_GETLINK, 0);
int ret = 1;
msg = nlmsg_alloc_simple(RTM_GETLINK, 0);
- if (!msg || nlmsg_append(msg, &ifi, sizeof(ifi), 0) ||
- nla_put_string(msg, IFLA_IFNAME, dev->ifname))
+ if (!msg)
goto out;
goto out;
+ if (nlmsg_append(msg, &ifi, sizeof(ifi), 0) ||
+ nla_put_string(msg, IFLA_IFNAME, dev->ifname))
+ goto free;
+
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, cb_if_check_valid, &chk);
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, cb_if_check_ack, &chk);
nl_cb_err(cb, NL_CB_CUSTOM, cb_if_check_error, &chk);
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, cb_if_check_valid, &chk);
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, cb_if_check_ack, &chk);
nl_cb_err(cb, NL_CB_CUSTOM, cb_if_check_error, &chk);
@@
-1307,9
+1310,10
@@
int system_if_check(struct device *dev)
while (chk.pending > 0)
nl_recvmsgs(sock_rtnl, cb);
while (chk.pending > 0)
nl_recvmsgs(sock_rtnl, cb);
- nlmsg_free(msg);
ret = chk.pending;
ret = chk.pending;
+free:
+ nlmsg_free(msg);
out:
nl_cb_put(cb);
return ret;
out:
nl_cb_put(cb);
return ret;