Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: make nlmsg_end() and genlmsg_end() void

Contrary to common expectations for an "int" return, these functions
return only a positive value -- if used correctly they cannot even
return 0 because the message header will necessarily be in the skb.

This makes the very common pattern of

if (genlmsg_end(...) < 0) { ... }

be a whole bunch of dead code. Many places also simply do

return nlmsg_end(...);

and the caller is expected to deal with it.

This also commonly (at least for me) causes errors, because it is very
common to write

if (my_function(...))
/* error condition */

and if my_function() does "return nlmsg_end()" this is of course wrong.

Additionally, there's not a single place in the kernel that actually
needs the message length returned, and if anyone needs it later then
it'll be very easy to just use skb->len there.

Remove this, and make the functions void. This removes a bunch of dead
code as described above. The patch adds lines because I did

- return nlmsg_end(...);
+ nlmsg_end(...);
+ return 0;

I could have preserved all the function's return values by returning
skb->len, but instead I've audited all the places calling the affected
functions and found that none cared. A few places actually compared
the return value with <= 0 in dump functionality, but that could just
be changed to < 0 with no change in behaviour, so I opted for the more
efficient version.

One instance of the error I've made numerous times now is also present
in net/phonet/pn_netlink.c in the route_dumpit() function - it didn't
check for <0 or <=0 and thus broke out of the loop every single time.
I've preserved this since it will (I think) have caused the messages to
userspace to be formatted differently with just a single message for
every SKB returned to userspace. It's possible that this isn't needed
for the tools that actually use this, but I don't even know what they
are so couldn't test that changing this behaviour would be acceptable.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Johannes Berg and committed by
David S. Miller
053c095a ede58ef2

+203 -158
+1 -6
drivers/acpi/event.c
··· 100 100 struct acpi_genl_event *event; 101 101 void *msg_header; 102 102 int size; 103 - int result; 104 103 105 104 /* allocate memory */ 106 105 size = nla_total_size(sizeof(struct acpi_genl_event)) + ··· 136 137 event->data = data; 137 138 138 139 /* send multicast genetlink message */ 139 - result = genlmsg_end(skb, msg_header); 140 - if (result < 0) { 141 - nlmsg_free(skb); 142 - return result; 143 - } 140 + genlmsg_end(skb, msg_header); 144 141 145 142 genlmsg_multicast(&acpi_event_genl_family, skb, 0, 0, GFP_ATOMIC); 146 143 return 0;
+2 -1
drivers/net/ethernet/rocker/rocker.c
··· 3674 3674 if (vid && nla_put_u16(skb, NDA_VLAN, vid)) 3675 3675 goto nla_put_failure; 3676 3676 3677 - return nlmsg_end(skb, nlh); 3677 + nlmsg_end(skb, nlh); 3678 + return 0; 3678 3679 3679 3680 nla_put_failure: 3680 3681 nlmsg_cancel(skb, nlh);
+2 -1
drivers/net/vxlan.c
··· 363 363 if (nla_put(skb, NDA_CACHEINFO, sizeof(ci), &ci)) 364 364 goto nla_put_failure; 365 365 366 - return nlmsg_end(skb, nlh); 366 + nlmsg_end(skb, nlh); 367 + return 0; 367 368 368 369 nla_put_failure: 369 370 nlmsg_cancel(skb, nlh);
+2 -1
drivers/net/wireless/mac80211_hwsim.c
··· 2557 2557 if (res < 0) 2558 2558 goto out_err; 2559 2559 2560 - return genlmsg_end(skb, hdr); 2560 + genlmsg_end(skb, hdr); 2561 + return 0; 2561 2562 2562 2563 out_err: 2563 2564 genlmsg_cancel(skb, hdr);
+1 -7
drivers/scsi/pmcraid.c
··· 1473 1473 } 1474 1474 1475 1475 /* send genetlink multicast message to notify appplications */ 1476 - result = genlmsg_end(skb, msg_header); 1477 - 1478 - if (result < 0) { 1479 - pmcraid_err("genlmsg_end failed\n"); 1480 - nlmsg_free(skb); 1481 - return result; 1482 - } 1476 + genlmsg_end(skb, msg_header); 1483 1477 1484 1478 result = genlmsg_multicast(&pmcraid_event_family, skb, 1485 1479 0, 0, GFP_ATOMIC);
+1 -3
drivers/target/target_core_user.c
··· 784 784 if (ret < 0) 785 785 goto free_skb; 786 786 787 - ret = genlmsg_end(skb, msg_header); 788 - if (ret < 0) 789 - goto free_skb; 787 + genlmsg_end(skb, msg_header); 790 788 791 789 ret = genlmsg_multicast(&tcmu_genl_family, skb, 0, 792 790 TCMU_MCGRP_CONFIG, GFP_KERNEL);
+1 -5
drivers/thermal/thermal_core.c
··· 1759 1759 thermal_event->event = event; 1760 1760 1761 1761 /* send multicast genetlink message */ 1762 - result = genlmsg_end(skb, msg_header); 1763 - if (result < 0) { 1764 - nlmsg_free(skb); 1765 - return result; 1766 - } 1762 + genlmsg_end(skb, msg_header); 1767 1763 1768 1764 result = genlmsg_multicast(&thermal_event_genl_family, skb, 0, 1769 1765 0, GFP_ATOMIC);
+1 -6
fs/dlm/netlink.c
··· 56 56 { 57 57 struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data); 58 58 void *data = genlmsg_data(genlhdr); 59 - int rv; 60 59 61 - rv = genlmsg_end(skb, data); 62 - if (rv < 0) { 63 - nlmsg_free(skb); 64 - return rv; 65 - } 60 + genlmsg_end(skb, data); 66 61 67 62 return genlmsg_unicast(&init_net, skb, listener_nlportid); 68 63 }
+2 -2
include/net/genetlink.h
··· 245 245 * @skb: socket buffer the message is stored in 246 246 * @hdr: user specific header 247 247 */ 248 - static inline int genlmsg_end(struct sk_buff *skb, void *hdr) 248 + static inline void genlmsg_end(struct sk_buff *skb, void *hdr) 249 249 { 250 - return nlmsg_end(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); 250 + nlmsg_end(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); 251 251 } 252 252 253 253 /**
+1 -5
include/net/netlink.h
··· 490 490 * Corrects the netlink message header to include the appeneded 491 491 * attributes. Only necessary if attributes have been added to 492 492 * the message. 493 - * 494 - * Returns the total data length of the skb. 495 493 */ 496 - static inline int nlmsg_end(struct sk_buff *skb, struct nlmsghdr *nlh) 494 + static inline void nlmsg_end(struct sk_buff *skb, struct nlmsghdr *nlh) 497 495 { 498 496 nlh->nlmsg_len = skb_tail_pointer(skb) - (unsigned char *)nlh; 499 - 500 - return skb->len; 501 497 } 502 498 503 499 /**
+2 -11
kernel/taskstats.c
··· 111 111 { 112 112 struct genlmsghdr *genlhdr = nlmsg_data(nlmsg_hdr(skb)); 113 113 void *reply = genlmsg_data(genlhdr); 114 - int rc; 115 114 116 - rc = genlmsg_end(skb, reply); 117 - if (rc < 0) { 118 - nlmsg_free(skb); 119 - return rc; 120 - } 115 + genlmsg_end(skb, reply); 121 116 122 117 return genlmsg_reply(skb, info); 123 118 } ··· 129 134 void *reply = genlmsg_data(genlhdr); 130 135 int rc, delcount = 0; 131 136 132 - rc = genlmsg_end(skb, reply); 133 - if (rc < 0) { 134 - nlmsg_free(skb); 135 - return; 136 - } 137 + genlmsg_end(skb, reply); 137 138 138 139 rc = 0; 139 140 down_read(&listeners->sem);
+2 -1
net/bridge/br_fdb.c
··· 633 633 if (fdb->vlan_id && nla_put(skb, NDA_VLAN, sizeof(u16), &fdb->vlan_id)) 634 634 goto nla_put_failure; 635 635 636 - return nlmsg_end(skb, nlh); 636 + nlmsg_end(skb, nlh); 637 + return 0; 637 638 638 639 nla_put_failure: 639 640 nlmsg_cancel(skb, nlh);
+2 -1
net/bridge/br_mdb.c
··· 190 190 191 191 nla_nest_end(skb, nest2); 192 192 nla_nest_end(skb, nest); 193 - return nlmsg_end(skb, nlh); 193 + nlmsg_end(skb, nlh); 194 + return 0; 194 195 195 196 end: 196 197 nla_nest_end(skb, nest);
+2 -1
net/bridge/br_netlink.c
··· 263 263 } 264 264 265 265 done: 266 - return nlmsg_end(skb, nlh); 266 + nlmsg_end(skb, nlh); 267 + return 0; 267 268 268 269 nla_put_failure: 269 270 nlmsg_cancel(skb, nlh);
+2 -1
net/can/gw.c
··· 575 575 goto cancel; 576 576 } 577 577 578 - return nlmsg_end(skb, nlh); 578 + nlmsg_end(skb, nlh); 579 + return 0; 579 580 580 581 cancel: 581 582 nlmsg_cancel(skb, nlh);
+2 -1
net/core/fib_rules.c
··· 609 609 if (ops->fill(rule, skb, frh) < 0) 610 610 goto nla_put_failure; 611 611 612 - return nlmsg_end(skb, nlh); 612 + nlmsg_end(skb, nlh); 613 + return 0; 613 614 614 615 nla_put_failure: 615 616 nlmsg_cancel(skb, nlh);
+8 -4
net/core/neighbour.c
··· 1884 1884 goto nla_put_failure; 1885 1885 1886 1886 read_unlock_bh(&tbl->lock); 1887 - return nlmsg_end(skb, nlh); 1887 + nlmsg_end(skb, nlh); 1888 + return 0; 1888 1889 1889 1890 nla_put_failure: 1890 1891 read_unlock_bh(&tbl->lock); ··· 1918 1917 goto errout; 1919 1918 1920 1919 read_unlock_bh(&tbl->lock); 1921 - return nlmsg_end(skb, nlh); 1920 + nlmsg_end(skb, nlh); 1921 + return 0; 1922 1922 errout: 1923 1923 read_unlock_bh(&tbl->lock); 1924 1924 nlmsg_cancel(skb, nlh); ··· 2204 2202 nla_put(skb, NDA_CACHEINFO, sizeof(ci), &ci)) 2205 2203 goto nla_put_failure; 2206 2204 2207 - return nlmsg_end(skb, nlh); 2205 + nlmsg_end(skb, nlh); 2206 + return 0; 2208 2207 2209 2208 nla_put_failure: 2210 2209 nlmsg_cancel(skb, nlh); ··· 2235 2232 if (nla_put(skb, NDA_DST, tbl->key_len, pn->key)) 2236 2233 goto nla_put_failure; 2237 2234 2238 - return nlmsg_end(skb, nlh); 2235 + nlmsg_end(skb, nlh); 2236 + return 0; 2239 2237 2240 2238 nla_put_failure: 2241 2239 nlmsg_cancel(skb, nlh);
+6 -3
net/core/rtnetlink.c
··· 1199 1199 1200 1200 nla_nest_end(skb, af_spec); 1201 1201 1202 - return nlmsg_end(skb, nlh); 1202 + nlmsg_end(skb, nlh); 1203 + return 0; 1203 1204 1204 1205 nla_put_failure: 1205 1206 nlmsg_cancel(skb, nlh); ··· 2327 2326 if (nla_put(skb, NDA_LLADDR, ETH_ALEN, addr)) 2328 2327 goto nla_put_failure; 2329 2328 2330 - return nlmsg_end(skb, nlh); 2329 + nlmsg_end(skb, nlh); 2330 + return 0; 2331 2331 2332 2332 nla_put_failure: 2333 2333 nlmsg_cancel(skb, nlh); ··· 2811 2809 2812 2810 nla_nest_end(skb, protinfo); 2813 2811 2814 - return nlmsg_end(skb, nlh); 2812 + nlmsg_end(skb, nlh); 2813 + return 0; 2815 2814 nla_put_failure: 2816 2815 nlmsg_cancel(skb, nlh); 2817 2816 return -EMSGSIZE;
+2 -1
net/decnet/dn_dev.c
··· 702 702 nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) || 703 703 nla_put_u32(skb, IFA_FLAGS, ifa_flags)) 704 704 goto nla_put_failure; 705 - return nlmsg_end(skb, nlh); 705 + nlmsg_end(skb, nlh); 706 + return 0; 706 707 707 708 nla_put_failure: 708 709 nlmsg_cancel(skb, nlh);
+2 -1
net/decnet/dn_route.c
··· 1616 1616 nla_put_u32(skb, RTA_IIF, rt->fld.flowidn_iif) < 0) 1617 1617 goto errout; 1618 1618 1619 - return nlmsg_end(skb, nlh); 1619 + nlmsg_end(skb, nlh); 1620 + return 0; 1620 1621 1621 1622 errout: 1622 1623 nlmsg_cancel(skb, nlh);
+2 -1
net/decnet/dn_table.c
··· 367 367 nla_nest_end(skb, mp_head); 368 368 } 369 369 370 - return nlmsg_end(skb, nlh); 370 + nlmsg_end(skb, nlh); 371 + return 0; 371 372 372 373 errout: 373 374 nlmsg_cancel(skb, nlh);
+2 -10
net/ieee802154/netlink.c
··· 63 63 struct nlmsghdr *nlh = nlmsg_hdr(msg); 64 64 void *hdr = genlmsg_data(nlmsg_data(nlh)); 65 65 66 - if (genlmsg_end(msg, hdr) < 0) 67 - goto out; 66 + genlmsg_end(msg, hdr); 68 67 69 68 return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC); 70 - out: 71 - nlmsg_free(msg); 72 - return -ENOBUFS; 73 69 } 74 70 75 71 struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, ··· 92 96 struct nlmsghdr *nlh = nlmsg_hdr(msg); 93 97 void *hdr = genlmsg_data(nlmsg_data(nlh)); 94 98 95 - if (genlmsg_end(msg, hdr) < 0) 96 - goto out; 99 + genlmsg_end(msg, hdr); 97 100 98 101 return genlmsg_reply(msg, info); 99 - out: 100 - nlmsg_free(msg); 101 - return -ENOBUFS; 102 102 } 103 103 104 104 static const struct genl_ops ieee8021154_ops[] = {
+2 -1
net/ieee802154/nl-mac.c
··· 136 136 } 137 137 138 138 wpan_phy_put(phy); 139 - return genlmsg_end(msg, hdr); 139 + genlmsg_end(msg, hdr); 140 + return 0; 140 141 141 142 nla_put_failure: 142 143 wpan_phy_put(phy);
+2 -1
net/ieee802154/nl-phy.c
··· 65 65 goto nla_put_failure; 66 66 mutex_unlock(&phy->pib_lock); 67 67 kfree(buf); 68 - return genlmsg_end(msg, hdr); 68 + genlmsg_end(msg, hdr); 69 + return 0; 69 70 70 71 nla_put_failure: 71 72 mutex_unlock(&phy->pib_lock);
+4 -2
net/ieee802154/nl802154.c
··· 306 306 goto nla_put_failure; 307 307 308 308 finish: 309 - return genlmsg_end(msg, hdr); 309 + genlmsg_end(msg, hdr); 310 + return 0; 310 311 311 312 nla_put_failure: 312 313 genlmsg_cancel(msg, hdr); ··· 490 489 if (nla_put_u8(msg, NL802154_ATTR_LBT_MODE, wpan_dev->lbt)) 491 490 goto nla_put_failure; 492 491 493 - return genlmsg_end(msg, hdr); 492 + genlmsg_end(msg, hdr); 493 + return 0; 494 494 495 495 nla_put_failure: 496 496 genlmsg_cancel(msg, hdr);
+5 -3
net/ipv4/devinet.c
··· 1522 1522 preferred, valid)) 1523 1523 goto nla_put_failure; 1524 1524 1525 - return nlmsg_end(skb, nlh); 1525 + nlmsg_end(skb, nlh); 1526 + return 0; 1526 1527 1527 1528 nla_put_failure: 1528 1529 nlmsg_cancel(skb, nlh); ··· 1567 1566 if (inet_fill_ifaddr(skb, ifa, 1568 1567 NETLINK_CB(cb->skb).portid, 1569 1568 cb->nlh->nlmsg_seq, 1570 - RTM_NEWADDR, NLM_F_MULTI) <= 0) { 1569 + RTM_NEWADDR, NLM_F_MULTI) < 0) { 1571 1570 rcu_read_unlock(); 1572 1571 goto done; 1573 1572 } ··· 1750 1749 IPV4_DEVCONF(*devconf, PROXY_ARP)) < 0) 1751 1750 goto nla_put_failure; 1752 1751 1753 - return nlmsg_end(skb, nlh); 1752 + nlmsg_end(skb, nlh); 1753 + return 0; 1754 1754 1755 1755 nla_put_failure: 1756 1756 nlmsg_cancel(skb, nlh);
+2 -1
net/ipv4/fib_semantics.c
··· 1091 1091 nla_nest_end(skb, mp); 1092 1092 } 1093 1093 #endif 1094 - return nlmsg_end(skb, nlh); 1094 + nlmsg_end(skb, nlh); 1095 + return 0; 1095 1096 1096 1097 nla_put_failure: 1097 1098 nlmsg_cancel(skb, nlh);
+6 -3
net/ipv4/inet_diag.c
··· 203 203 icsk->icsk_ca_ops->get_info(sk, ext, skb); 204 204 205 205 out: 206 - return nlmsg_end(skb, nlh); 206 + nlmsg_end(skb, nlh); 207 + return 0; 207 208 208 209 errout: 209 210 nlmsg_cancel(skb, nlh); ··· 272 271 } 273 272 #endif 274 273 275 - return nlmsg_end(skb, nlh); 274 + nlmsg_end(skb, nlh); 275 + return 0; 276 276 } 277 277 278 278 static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, ··· 760 758 } 761 759 #endif 762 760 763 - return nlmsg_end(skb, nlh); 761 + nlmsg_end(skb, nlh); 762 + return 0; 764 763 } 765 764 766 765 static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
+2 -1
net/ipv4/ipmr.c
··· 2290 2290 if (err < 0 && err != -ENOENT) 2291 2291 goto nla_put_failure; 2292 2292 2293 - return nlmsg_end(skb, nlh); 2293 + nlmsg_end(skb, nlh); 2294 + return 0; 2294 2295 2295 2296 nla_put_failure: 2296 2297 nlmsg_cancel(skb, nlh);
+2 -1
net/ipv4/route.c
··· 2390 2390 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) 2391 2391 goto nla_put_failure; 2392 2392 2393 - return nlmsg_end(skb, nlh); 2393 + nlmsg_end(skb, nlh); 2394 + return 0; 2394 2395 2395 2396 nla_put_failure: 2396 2397 nlmsg_cancel(skb, nlh);
+2 -1
net/ipv4/tcp_metrics.c
··· 886 886 if (tcp_metrics_fill_info(skb, tm) < 0) 887 887 goto nla_put_failure; 888 888 889 - return genlmsg_end(skb, hdr); 889 + genlmsg_end(skb, hdr); 890 + return 0; 890 891 891 892 nla_put_failure: 892 893 genlmsg_cancel(skb, hdr);
+19 -13
net/ipv6/addrconf.c
··· 489 489 nla_put_s32(skb, NETCONFA_PROXY_NEIGH, devconf->proxy_ndp) < 0) 490 490 goto nla_put_failure; 491 491 492 - return nlmsg_end(skb, nlh); 492 + nlmsg_end(skb, nlh); 493 + return 0; 493 494 494 495 nla_put_failure: 495 496 nlmsg_cancel(skb, nlh); ··· 620 619 cb->nlh->nlmsg_seq, 621 620 RTM_NEWNETCONF, 622 621 NLM_F_MULTI, 623 - -1) <= 0) { 622 + -1) < 0) { 624 623 rcu_read_unlock(); 625 624 goto done; 626 625 } ··· 636 635 NETLINK_CB(cb->skb).portid, 637 636 cb->nlh->nlmsg_seq, 638 637 RTM_NEWNETCONF, NLM_F_MULTI, 639 - -1) <= 0) 638 + -1) < 0) 640 639 goto done; 641 640 else 642 641 h++; ··· 647 646 NETLINK_CB(cb->skb).portid, 648 647 cb->nlh->nlmsg_seq, 649 648 RTM_NEWNETCONF, NLM_F_MULTI, 650 - -1) <= 0) 649 + -1) < 0) 651 650 goto done; 652 651 else 653 652 h++; ··· 4048 4047 if (nla_put_u32(skb, IFA_FLAGS, ifa->flags) < 0) 4049 4048 goto error; 4050 4049 4051 - return nlmsg_end(skb, nlh); 4050 + nlmsg_end(skb, nlh); 4051 + return 0; 4052 4052 4053 4053 error: 4054 4054 nlmsg_cancel(skb, nlh); ··· 4078 4076 return -EMSGSIZE; 4079 4077 } 4080 4078 4081 - return nlmsg_end(skb, nlh); 4079 + nlmsg_end(skb, nlh); 4080 + return 0; 4082 4081 } 4083 4082 4084 4083 static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca, ··· 4104 4101 return -EMSGSIZE; 4105 4102 } 4106 4103 4107 - return nlmsg_end(skb, nlh); 4104 + nlmsg_end(skb, nlh); 4105 + return 0; 4108 4106 } 4109 4107 4110 4108 enum addr_type_t { ··· 4138 4134 cb->nlh->nlmsg_seq, 4139 4135 RTM_NEWADDR, 4140 4136 NLM_F_MULTI); 4141 - if (err <= 0) 4137 + if (err < 0) 4142 4138 break; 4143 4139 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 4144 4140 } ··· 4155 4151 cb->nlh->nlmsg_seq, 4156 4152 RTM_GETMULTICAST, 4157 4153 NLM_F_MULTI); 4158 - if (err <= 0) 4154 + if (err < 0) 4159 4155 break; 4160 4156 } 4161 4157 break; ··· 4170 4166 cb->nlh->nlmsg_seq, 4171 4167 RTM_GETANYCAST, 4172 4168 NLM_F_MULTI); 4173 - if (err <= 0) 4169 + if (err < 0) 4174 4170 break; 4175 4171 } 4176 4172 break; ··· 4642 4638 goto nla_put_failure; 4643 4639 4644 4640 nla_nest_end(skb, protoinfo); 4645 - return nlmsg_end(skb, nlh); 4641 + nlmsg_end(skb, nlh); 4642 + return 0; 4646 4643 4647 4644 nla_put_failure: 4648 4645 nlmsg_cancel(skb, nlh); ··· 4675 4670 if (inet6_fill_ifinfo(skb, idev, 4676 4671 NETLINK_CB(cb->skb).portid, 4677 4672 cb->nlh->nlmsg_seq, 4678 - RTM_NEWLINK, NLM_F_MULTI) <= 0) 4673 + RTM_NEWLINK, NLM_F_MULTI) < 0) 4679 4674 goto out; 4680 4675 cont: 4681 4676 idx++; ··· 4752 4747 ci.valid_time = ntohl(pinfo->valid); 4753 4748 if (nla_put(skb, PREFIX_CACHEINFO, sizeof(ci), &ci)) 4754 4749 goto nla_put_failure; 4755 - return nlmsg_end(skb, nlh); 4750 + nlmsg_end(skb, nlh); 4751 + return 0; 4756 4752 4757 4753 nla_put_failure: 4758 4754 nlmsg_cancel(skb, nlh);
+3 -2
net/ipv6/addrlabel.c
··· 490 490 return -EMSGSIZE; 491 491 } 492 492 493 - return nlmsg_end(skb, nlh); 493 + nlmsg_end(skb, nlh); 494 + return 0; 494 495 } 495 496 496 497 static int ip6addrlbl_dump(struct sk_buff *skb, struct netlink_callback *cb) ··· 511 510 cb->nlh->nlmsg_seq, 512 511 RTM_NEWADDRLABEL, 513 512 NLM_F_MULTI); 514 - if (err <= 0) 513 + if (err < 0) 515 514 break; 516 515 } 517 516 idx++;
-1
net/ipv6/ip6_fib.c
··· 277 277 w->leaf = rt; 278 278 return 1; 279 279 } 280 - WARN_ON(res == 0); 281 280 } 282 281 w->leaf = NULL; 283 282 return 0;
+2 -1
net/ipv6/ip6mr.c
··· 2388 2388 if (err < 0 && err != -ENOENT) 2389 2389 goto nla_put_failure; 2390 2390 2391 - return nlmsg_end(skb, nlh); 2391 + nlmsg_end(skb, nlh); 2392 + return 0; 2392 2393 2393 2394 nla_put_failure: 2394 2395 nlmsg_cancel(skb, nlh);
+2 -1
net/ipv6/route.c
··· 2725 2725 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, rt->dst.error) < 0) 2726 2726 goto nla_put_failure; 2727 2727 2728 - return nlmsg_end(skb, nlh); 2728 + nlmsg_end(skb, nlh); 2729 + return 0; 2729 2730 2730 2731 nla_put_failure: 2731 2732 nlmsg_cancel(skb, nlh);
+6 -4
net/l2tp/l2tp_netlink.c
··· 390 390 } 391 391 392 392 out: 393 - return genlmsg_end(skb, hdr); 393 + genlmsg_end(skb, hdr); 394 + return 0; 394 395 395 396 nla_put_failure: 396 397 genlmsg_cancel(skb, hdr); ··· 452 451 453 452 if (l2tp_nl_tunnel_send(skb, NETLINK_CB(cb->skb).portid, 454 453 cb->nlh->nlmsg_seq, NLM_F_MULTI, 455 - tunnel, L2TP_CMD_TUNNEL_GET) <= 0) 454 + tunnel, L2TP_CMD_TUNNEL_GET) < 0) 456 455 goto out; 457 456 458 457 ti++; ··· 753 752 goto nla_put_failure; 754 753 nla_nest_end(skb, nest); 755 754 756 - return genlmsg_end(skb, hdr); 755 + genlmsg_end(skb, hdr); 756 + return 0; 757 757 758 758 nla_put_failure: 759 759 genlmsg_cancel(skb, hdr); ··· 818 816 819 817 if (l2tp_nl_session_send(skb, NETLINK_CB(cb->skb).portid, 820 818 cb->nlh->nlmsg_seq, NLM_F_MULTI, 821 - session, L2TP_CMD_SESSION_GET) <= 0) 819 + session, L2TP_CMD_SESSION_GET) < 0) 822 820 break; 823 821 824 822 si++;
+6 -3
net/netfilter/ipvs/ip_vs_ctl.c
··· 2887 2887 if (ip_vs_genl_fill_service(skb, svc) < 0) 2888 2888 goto nla_put_failure; 2889 2889 2890 - return genlmsg_end(skb, hdr); 2890 + genlmsg_end(skb, hdr); 2891 + return 0; 2891 2892 2892 2893 nla_put_failure: 2893 2894 genlmsg_cancel(skb, hdr); ··· 3080 3079 if (ip_vs_genl_fill_dest(skb, dest) < 0) 3081 3080 goto nla_put_failure; 3082 3081 3083 - return genlmsg_end(skb, hdr); 3082 + genlmsg_end(skb, hdr); 3083 + return 0; 3084 3084 3085 3085 nla_put_failure: 3086 3086 genlmsg_cancel(skb, hdr); ··· 3217 3215 if (ip_vs_genl_fill_daemon(skb, state, mcast_ifn, syncid)) 3218 3216 goto nla_put_failure; 3219 3217 3220 - return genlmsg_end(skb, hdr); 3218 + genlmsg_end(skb, hdr); 3219 + return 0; 3221 3220 3222 3221 nla_put_failure: 3223 3222 genlmsg_cancel(skb, hdr);
+12 -6
net/netfilter/nf_tables_api.c
··· 427 427 nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use))) 428 428 goto nla_put_failure; 429 429 430 - return nlmsg_end(skb, nlh); 430 + nlmsg_end(skb, nlh); 431 + return 0; 431 432 432 433 nla_put_failure: 433 434 nlmsg_trim(skb, nlh); ··· 972 971 if (nla_put_be32(skb, NFTA_CHAIN_USE, htonl(chain->use))) 973 972 goto nla_put_failure; 974 973 975 - return nlmsg_end(skb, nlh); 974 + nlmsg_end(skb, nlh); 975 + return 0; 976 976 977 977 nla_put_failure: 978 978 nlmsg_trim(skb, nlh); ··· 1709 1707 nla_put(skb, NFTA_RULE_USERDATA, rule->ulen, nft_userdata(rule))) 1710 1708 goto nla_put_failure; 1711 1709 1712 - return nlmsg_end(skb, nlh); 1710 + nlmsg_end(skb, nlh); 1711 + return 0; 1713 1712 1714 1713 nla_put_failure: 1715 1714 nlmsg_trim(skb, nlh); ··· 2364 2361 goto nla_put_failure; 2365 2362 nla_nest_end(skb, desc); 2366 2363 2367 - return nlmsg_end(skb, nlh); 2364 + nlmsg_end(skb, nlh); 2365 + return 0; 2368 2366 2369 2367 nla_put_failure: 2370 2368 nlmsg_trim(skb, nlh); ··· 3039 3035 3040 3036 nla_nest_end(skb, nest); 3041 3037 3042 - return nlmsg_end(skb, nlh); 3038 + nlmsg_end(skb, nlh); 3039 + return 0; 3043 3040 3044 3041 nla_put_failure: 3045 3042 nlmsg_trim(skb, nlh); ··· 3329 3324 if (nla_put_be32(skb, NFTA_GEN_ID, htonl(net->nft.base_seq))) 3330 3325 goto nla_put_failure; 3331 3326 3332 - return nlmsg_end(skb, nlh); 3327 + nlmsg_end(skb, nlh); 3328 + return 0; 3333 3329 3334 3330 nla_put_failure: 3335 3331 nlmsg_trim(skb, nlh);
+2 -1
net/netlabel/netlabel_cipso_v4.c
··· 641 641 if (ret_val != 0) 642 642 goto listall_cb_failure; 643 643 644 - return genlmsg_end(cb_arg->skb, data); 644 + genlmsg_end(cb_arg->skb, data); 645 + return 0; 645 646 646 647 listall_cb_failure: 647 648 genlmsg_cancel(cb_arg->skb, data);
+4 -2
net/netlabel/netlabel_mgmt.c
··· 456 456 goto listall_cb_failure; 457 457 458 458 cb_arg->seq++; 459 - return genlmsg_end(cb_arg->skb, data); 459 + genlmsg_end(cb_arg->skb, data); 460 + return 0; 460 461 461 462 listall_cb_failure: 462 463 genlmsg_cancel(cb_arg->skb, data); ··· 621 620 if (ret_val != 0) 622 621 goto protocols_cb_failure; 623 622 624 - return genlmsg_end(skb, data); 623 + genlmsg_end(skb, data); 624 + return 0; 625 625 626 626 protocols_cb_failure: 627 627 genlmsg_cancel(skb, data);
+2 -1
net/netlabel/netlabel_unlabeled.c
··· 1163 1163 goto list_cb_failure; 1164 1164 1165 1165 cb_arg->seq++; 1166 - return genlmsg_end(cb_arg->skb, data); 1166 + genlmsg_end(cb_arg->skb, data); 1167 + return 0; 1167 1168 1168 1169 list_cb_failure: 1169 1170 genlmsg_cancel(cb_arg->skb, data);
+2 -1
net/netlink/diag.c
··· 91 91 sk_diag_put_rings_cfg(sk, skb)) 92 92 goto out_nlmsg_trim; 93 93 94 - return nlmsg_end(skb, nlh); 94 + nlmsg_end(skb, nlh); 95 + return 0; 95 96 96 97 out_nlmsg_trim: 97 98 nlmsg_cancel(skb, nlh);
+4 -2
net/netlink/genetlink.c
··· 756 756 nla_nest_end(skb, nla_grps); 757 757 } 758 758 759 - return genlmsg_end(skb, hdr); 759 + genlmsg_end(skb, hdr); 760 + return 0; 760 761 761 762 nla_put_failure: 762 763 genlmsg_cancel(skb, hdr); ··· 797 796 nla_nest_end(skb, nest); 798 797 nla_nest_end(skb, nla_grps); 799 798 800 - return genlmsg_end(skb, hdr); 799 + genlmsg_end(skb, hdr); 800 + return 0; 801 801 802 802 nla_put_failure: 803 803 genlmsg_cancel(skb, hdr);
+7 -5
net/nfc/netlink.c
··· 102 102 goto nla_put_failure; 103 103 } 104 104 105 - return genlmsg_end(msg, hdr); 105 + genlmsg_end(msg, hdr); 106 + return 0; 106 107 107 108 nla_put_failure: 108 109 genlmsg_cancel(msg, hdr); ··· 519 518 nla_put_u8(msg, NFC_ATTR_RF_MODE, dev->rf_mode)) 520 519 goto nla_put_failure; 521 520 522 - return genlmsg_end(msg, hdr); 521 + genlmsg_end(msg, hdr); 522 + return 0; 523 523 524 524 nla_put_failure: 525 525 genlmsg_cancel(msg, hdr); ··· 910 908 nla_put_u16(msg, NFC_ATTR_LLC_PARAM_MIUX, be16_to_cpu(local->miux))) 911 909 goto nla_put_failure; 912 910 913 - return genlmsg_end(msg, hdr); 911 + genlmsg_end(msg, hdr); 912 + return 0; 914 913 915 914 nla_put_failure: 916 915 ··· 1250 1247 nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type)) 1251 1248 goto nla_put_failure; 1252 1249 1253 - if (genlmsg_end(msg, hdr) < 0) 1254 - goto nla_put_failure; 1250 + genlmsg_end(msg, hdr); 1255 1251 } 1256 1252 1257 1253 return 0;
+6 -3
net/openvswitch/datapath.c
··· 799 799 if (err) 800 800 goto error; 801 801 802 - return genlmsg_end(skb, ovs_header); 802 + genlmsg_end(skb, ovs_header); 803 + return 0; 803 804 804 805 error: 805 806 genlmsg_cancel(skb, ovs_header); ··· 1350 1349 if (nla_put_u32(skb, OVS_DP_ATTR_USER_FEATURES, dp->user_features)) 1351 1350 goto nla_put_failure; 1352 1351 1353 - return genlmsg_end(skb, ovs_header); 1352 + genlmsg_end(skb, ovs_header); 1353 + return 0; 1354 1354 1355 1355 nla_put_failure: 1356 1356 genlmsg_cancel(skb, ovs_header); ··· 1725 1723 if (err == -EMSGSIZE) 1726 1724 goto error; 1727 1725 1728 - return genlmsg_end(skb, ovs_header); 1726 + genlmsg_end(skb, ovs_header); 1727 + return 0; 1729 1728 1730 1729 nla_put_failure: 1731 1730 err = -EMSGSIZE;
+2 -1
net/packet/diag.c
··· 177 177 PACKET_DIAG_FILTER)) 178 178 goto out_nlmsg_trim; 179 179 180 - return nlmsg_end(skb, nlh); 180 + nlmsg_end(skb, nlh); 181 + return 0; 181 182 182 183 out_nlmsg_trim: 183 184 nlmsg_cancel(skb, nlh);
+11 -5
net/phonet/pn_netlink.c
··· 121 121 ifm->ifa_index = dev->ifindex; 122 122 if (nla_put_u8(skb, IFA_LOCAL, addr)) 123 123 goto nla_put_failure; 124 - return nlmsg_end(skb, nlh); 124 + nlmsg_end(skb, nlh); 125 + return 0; 125 126 126 127 nla_put_failure: 127 128 nlmsg_cancel(skb, nlh); ··· 191 190 if (nla_put_u8(skb, RTA_DST, dst) || 192 191 nla_put_u32(skb, RTA_OIF, dev->ifindex)) 193 192 goto nla_put_failure; 194 - return nlmsg_end(skb, nlh); 193 + nlmsg_end(skb, nlh); 194 + return 0; 195 195 196 196 nla_put_failure: 197 197 nlmsg_cancel(skb, nlh); ··· 284 282 285 283 if (addr_idx++ < addr_start_idx) 286 284 continue; 287 - if (fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).portid, 288 - cb->nlh->nlmsg_seq, RTM_NEWROUTE)) 289 - goto out; 285 + fill_route(skb, dev, addr << 2, NETLINK_CB(cb->skb).portid, 286 + cb->nlh->nlmsg_seq, RTM_NEWROUTE); 287 + /* fill_route() used to return > 0 (or negative errors) but 288 + * never 0 - ignore the return value and just go out to 289 + * call dumpit again from outside to preserve the behavior 290 + */ 291 + goto out; 290 292 } 291 293 292 294 out:
+2 -1
net/unix/diag.c
··· 155 155 if (nla_put_u8(skb, UNIX_DIAG_SHUTDOWN, sk->sk_shutdown)) 156 156 goto out_nlmsg_trim; 157 157 158 - return nlmsg_end(skb, nlh); 158 + nlmsg_end(skb, nlh); 159 + return 0; 159 160 160 161 out_nlmsg_trim: 161 162 nlmsg_cancel(skb, nlh);
+18 -9
net/wireless/nl80211.c
··· 1721 1721 break; 1722 1722 } 1723 1723 finish: 1724 - return genlmsg_end(msg, hdr); 1724 + genlmsg_end(msg, hdr); 1725 + return 0; 1725 1726 1726 1727 nla_put_failure: 1727 1728 genlmsg_cancel(msg, hdr); ··· 2405 2404 goto nla_put_failure; 2406 2405 } 2407 2406 2408 - return genlmsg_end(msg, hdr); 2407 + genlmsg_end(msg, hdr); 2408 + return 0; 2409 2409 2410 2410 nla_put_failure: 2411 2411 genlmsg_cancel(msg, hdr); ··· 3827 3825 sinfo->assoc_req_ies)) 3828 3826 goto nla_put_failure; 3829 3827 3830 - return genlmsg_end(msg, hdr); 3828 + genlmsg_end(msg, hdr); 3829 + return 0; 3831 3830 3832 3831 nla_put_failure: 3833 3832 genlmsg_cancel(msg, hdr); ··· 4558 4555 4559 4556 nla_nest_end(msg, pinfoattr); 4560 4557 4561 - return genlmsg_end(msg, hdr); 4558 + genlmsg_end(msg, hdr); 4559 + return 0; 4562 4560 4563 4561 nla_put_failure: 4564 4562 genlmsg_cancel(msg, hdr); ··· 5511 5507 nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG)) 5512 5508 goto nla_put_failure; 5513 5509 5514 - return genlmsg_end(msg, hdr); 5510 + genlmsg_end(msg, hdr); 5511 + return 0; 5515 5512 5516 5513 nla_put_failure: 5517 5514 genlmsg_cancel(msg, hdr); ··· 6582 6577 6583 6578 nla_nest_end(msg, bss); 6584 6579 6585 - return genlmsg_end(msg, hdr); 6580 + genlmsg_end(msg, hdr); 6581 + return 0; 6586 6582 6587 6583 fail_unlock_rcu: 6588 6584 rcu_read_unlock(); ··· 6692 6686 6693 6687 nla_nest_end(msg, infoattr); 6694 6688 6695 - return genlmsg_end(msg, hdr); 6689 + genlmsg_end(msg, hdr); 6690 + return 0; 6696 6691 6697 6692 nla_put_failure: 6698 6693 genlmsg_cancel(msg, hdr); ··· 11032 11025 /* ignore errors and send incomplete event anyway */ 11033 11026 nl80211_add_scan_req(msg, rdev); 11034 11027 11035 - return genlmsg_end(msg, hdr); 11028 + genlmsg_end(msg, hdr); 11029 + return 0; 11036 11030 11037 11031 nla_put_failure: 11038 11032 genlmsg_cancel(msg, hdr); ··· 11056 11048 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) 11057 11049 goto nla_put_failure; 11058 11050 11059 - return genlmsg_end(msg, hdr); 11051 + genlmsg_end(msg, hdr); 11052 + return 0; 11060 11053 11061 11054 nla_put_failure: 11062 11055 genlmsg_cancel(msg, hdr);
+18 -9
net/xfrm/xfrm_user.c
··· 1019 1019 return err; 1020 1020 } 1021 1021 1022 - return nlmsg_end(skb, nlh); 1022 + nlmsg_end(skb, nlh); 1023 + return 0; 1023 1024 } 1024 1025 1025 1026 static int xfrm_set_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ··· 1122 1121 return err; 1123 1122 } 1124 1123 1125 - return nlmsg_end(skb, nlh); 1124 + nlmsg_end(skb, nlh); 1125 + return 0; 1126 1126 } 1127 1127 1128 1128 static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ··· 1844 1842 if (err) 1845 1843 goto out_cancel; 1846 1844 1847 - return nlmsg_end(skb, nlh); 1845 + nlmsg_end(skb, nlh); 1846 + return 0; 1848 1847 1849 1848 out_cancel: 1850 1849 nlmsg_cancel(skb, nlh); ··· 2285 2282 goto out_cancel; 2286 2283 } 2287 2284 2288 - return nlmsg_end(skb, nlh); 2285 + nlmsg_end(skb, nlh); 2286 + return 0; 2289 2287 2290 2288 out_cancel: 2291 2289 nlmsg_cancel(skb, nlh); ··· 2494 2490 if (err) 2495 2491 return err; 2496 2492 2497 - return nlmsg_end(skb, nlh); 2493 + nlmsg_end(skb, nlh); 2494 + return 0; 2498 2495 } 2499 2496 2500 2497 static int xfrm_exp_state_notify(struct xfrm_state *x, const struct km_event *c) ··· 2717 2712 return err; 2718 2713 } 2719 2714 2720 - return nlmsg_end(skb, nlh); 2715 + nlmsg_end(skb, nlh); 2716 + return 0; 2721 2717 } 2722 2718 2723 2719 static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, ··· 2833 2827 } 2834 2828 upe->hard = !!hard; 2835 2829 2836 - return nlmsg_end(skb, nlh); 2830 + nlmsg_end(skb, nlh); 2831 + return 0; 2837 2832 } 2838 2833 2839 2834 static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c) ··· 2993 2986 return err; 2994 2987 } 2995 2988 } 2996 - return nlmsg_end(skb, nlh); 2989 + nlmsg_end(skb, nlh); 2990 + return 0; 2997 2991 } 2998 2992 2999 2993 static int xfrm_send_report(struct net *net, u8 proto, ··· 3039 3031 um->old_sport = x->encap->encap_sport; 3040 3032 um->reqid = x->props.reqid; 3041 3033 3042 - return nlmsg_end(skb, nlh); 3034 + nlmsg_end(skb, nlh); 3035 + return 0; 3043 3036 } 3044 3037 3045 3038 static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,