diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-10 19:46:49 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-10 19:47:08 (GMT) |
commit | cfc57ce3596cfe9dacf01219f118534fb2686137 (patch) | |
tree | 0d23d000a91b37fd7be81de6750cc65a9202e7d1 | |
parent | 6608cd5d7242a8b58e62208e71b6c276434566ec (diff) | |
parent | 3d5e4883be79b70cc387d0b1c6bf05ff19fae8cc (diff) | |
download | libnl-cfc57ce3596cfe9dacf01219f118534fb2686137.zip libnl-cfc57ce3596cfe9dacf01219f118534fb2686137.tar.gz libnl-cfc57ce3596cfe9dacf01219f118534fb2686137.tar.bz2 |
Merge branch 'coverity-fixes'
http://lists.infradead.org/pipermail/libnl/2014-June/001475.html
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | lib/cache.c | 2 | ||||
-rw-r--r-- | lib/cache_mngr.c | 3 | ||||
-rw-r--r-- | lib/msg.c | 2 | ||||
-rw-r--r-- | lib/netfilter/ct.c | 3 | ||||
-rw-r--r-- | lib/netfilter/exp.c | 3 | ||||
-rw-r--r-- | lib/netfilter/log_msg.c | 3 | ||||
-rw-r--r-- | lib/netfilter/queue_msg.c | 3 | ||||
-rw-r--r-- | lib/object.c | 4 | ||||
-rw-r--r-- | lib/route/cls/ematch.c | 9 | ||||
-rw-r--r-- | lib/route/link.c | 4 | ||||
-rw-r--r-- | lib/route/link/vlan.c | 2 | ||||
-rw-r--r-- | lib/route/pktloc.c | 5 | ||||
-rw-r--r-- | src/nl-route-get.c | 8 |
13 files changed, 26 insertions, 25 deletions
diff --git a/lib/cache.c b/lib/cache.c index 5418051..b4f9649 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -1154,7 +1154,7 @@ void nl_cache_dump_filter(struct nl_cache *cache, if (!ops->oo_dump[type]) return; - if (params->dp_buf) + if (params && params->dp_buf) memset(params->dp_buf, 0, params->dp_buflen); nl_list_for_each_entry(obj, &cache->c_items, ce_list) { diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c index 7fb1ed0..36f5ca8 100644 --- a/lib/cache_mngr.c +++ b/lib/cache_mngr.c @@ -515,9 +515,10 @@ void nl_cache_mngr_free(struct nl_cache_mngr *mngr) } free(mngr->cm_assocs); - free(mngr); NL_DBG(1, "Cache manager %p freed\n", mngr); + + free(mngr); } /** @} */ @@ -569,8 +569,8 @@ void nlmsg_free(struct nl_msg *msg) if (msg->nm_refcnt <= 0) { free(msg->nm_nlh); - free(msg); NL_DBG(2, "msg %p: Freed\n", msg); + free(msg); } } diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 04f9d01..36a83db 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -414,10 +414,9 @@ static int ct_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, int err; if ((err = nfnlmsg_ct_parse(nlh, &ct)) < 0) - goto errout; + return err; err = pp->pp_cb((struct nl_object *) ct, pp); -errout: nfnl_ct_put(ct); return err; } diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index 86ed8d1..9cfdd2b 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -298,10 +298,9 @@ static int exp_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, int err; if ((err = nfnlmsg_exp_parse(nlh, &exp)) < 0) - goto errout; + return err; err = pp->pp_cb((struct nl_object *) exp, pp); -errout: nfnl_exp_put(exp); return err; } diff --git a/lib/netfilter/log_msg.c b/lib/netfilter/log_msg.c index 6e09da2..5ffdaf8 100644 --- a/lib/netfilter/log_msg.c +++ b/lib/netfilter/log_msg.c @@ -174,10 +174,9 @@ static int log_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, int err; if ((err = nfnlmsg_log_msg_parse(nlh, &msg)) < 0) - goto errout; + return err; err = pp->pp_cb((struct nl_object *) msg, pp); -errout: nfnl_log_msg_put(msg); return err; } diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c index 1425577..3388923 100644 --- a/lib/netfilter/queue_msg.c +++ b/lib/netfilter/queue_msg.c @@ -153,10 +153,9 @@ static int queue_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, int err; if ((err = nfnlmsg_queue_msg_parse(nlh, &msg)) < 0) - goto errout; + return err; err = pp->pp_cb((struct nl_object *) msg, pp); -errout: nfnl_queue_msg_put(msg); return err; } diff --git a/lib/object.c b/lib/object.c index 405912b..52bc873 100644 --- a/lib/object.c +++ b/lib/object.c @@ -185,9 +185,9 @@ void nl_object_free(struct nl_object *obj) if (ops->oo_free_data) ops->oo_free_data(obj); - free(obj); - NL_DBG(4, "Freed object %p\n", obj); + + free(obj); } /** @} */ diff --git a/lib/route/cls/ematch.c b/lib/route/cls/ematch.c index 89b5067..6cbe274 100644 --- a/lib/route/cls/ematch.c +++ b/lib/route/cls/ematch.c @@ -282,9 +282,10 @@ void rtnl_ematch_tree_free(struct rtnl_ematch_tree *tree) return; free_ematch_list(&tree->et_list); - free(tree); NL_DBG(2, "Freed ematch tree %p\n", tree); + + free(tree); } /** @@ -653,9 +654,7 @@ int rtnl_ematch_parse_expr(const char *expr, char **errp, goto errout; } - if (scanner) - ematch_lex_destroy(scanner); - + ematch_lex_destroy(scanner); *result = tree; return 0; @@ -693,7 +692,7 @@ static const char *operand_txt[] = { char *rtnl_ematch_opnd2txt(uint8_t opnd, char *buf, size_t len) { snprintf(buf, len, "%s", - opnd <= ARRAY_SIZE(operand_txt) ? operand_txt[opnd] : "?"); + opnd < ARRAY_SIZE(operand_txt) ? operand_txt[opnd] : "?"); return buf; } diff --git a/lib/route/link.c b/lib/route/link.c index 65e42ec..3d31ffc 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -2102,11 +2102,13 @@ const char *rtnl_link_get_ifalias(struct rtnl_link *link) void rtnl_link_set_ifalias(struct rtnl_link *link, const char *alias) { free(link->l_ifalias); - link->ce_mask &= ~LINK_ATTR_IFALIAS; if (alias) { link->l_ifalias = strdup(alias); link->ce_mask |= LINK_ATTR_IFALIAS; + } else { + link->l_ifalias = NULL; + link->ce_mask &= ~LINK_ATTR_IFALIAS; } } diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index 1a0d916..b9f0c66 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -145,7 +145,7 @@ static int vlan_parse(struct rtnl_link *link, struct nlattr *data, /* align to have a little reserve */ vi->vi_egress_size = (i + 32) & ~31; - vi->vi_egress_qos = calloc(vi->vi_egress_size, sizeof(*map)); + vi->vi_egress_qos = calloc(vi->vi_egress_size, sizeof(*vi->vi_egress_qos)); if (vi->vi_egress_qos == NULL) return -NLE_NOMEM; diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c index 9fcf4a4..27d63be 100644 --- a/lib/route/pktloc.c +++ b/lib/route/pktloc.c @@ -138,14 +138,13 @@ static int read_pktlocs(void) last_read = st.st_mtime; errout_scanner: - if (scanner) - pktloc_lex_destroy(scanner); + pktloc_lex_destroy(scanner); errout_close: fclose(fd); errout: free(path); - return 0; + return err; } /** @endcond */ diff --git a/src/nl-route-get.c b/src/nl-route-get.c index c2f07d4..9d9a448 100644 --- a/src/nl-route-get.c +++ b/src/nl-route-get.c @@ -65,8 +65,12 @@ int main(int argc, char *argv[]) }; m = nlmsg_alloc_simple(RTM_GETROUTE, 0); - nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO); - nla_put_addr(m, RTA_DST, dst); + if (!m) + nl_cli_fatal(ENOMEM, "out of memory"); + if (nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO) < 0) + nl_cli_fatal(ENOMEM, "out of memory"); + if (nla_put_addr(m, RTA_DST, dst) < 0) + nl_cli_fatal(ENOMEM, "out of memory"); err = nl_send_auto_complete(sock, m); nlmsg_free(m); |