aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge/br_netlink.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-02-01 02:16:40 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-02-08 15:38:41 -0500
commit26932566a42d46aee7e5d526cb34fba9380cad10 (patch)
tree3991d9209ddf2454ba4c71daccdc33951811dcf1 /net/bridge/br_netlink.c
parent2cf6c36cb46d69057db2ebae0d8ec352e065f48b (diff)
[NETLINK]: Don't BUG on undersized allocations
Currently netlink users BUG when the allocated skb for an event notification is undersized. While this is certainly a kernel bug, its not critical and crashing the kernel is too drastic, especially when considering that these errors have appeared multiple times in the past and it BUGs even if no listeners are present. This patch replaces BUG by WARN_ON and changes the notification functions to inform potential listeners of undersized allocations using a unique error code (EMSGSIZE). Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_netlink.c')
-rw-r--r--net/bridge/br_netlink.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index a9139682c49b..7d68b24b5654 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -45,7 +45,7 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
45 45
46 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); 46 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
47 if (nlh == NULL) 47 if (nlh == NULL)
48 return -ENOBUFS; 48 return -EMSGSIZE;
49 49
50 hdr = nlmsg_data(nlh); 50 hdr = nlmsg_data(nlh);
51 hdr->ifi_family = AF_BRIDGE; 51 hdr->ifi_family = AF_BRIDGE;
@@ -72,7 +72,8 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
72 return nlmsg_end(skb, nlh); 72 return nlmsg_end(skb, nlh);
73 73
74nla_put_failure: 74nla_put_failure:
75 return nlmsg_cancel(skb, nlh); 75 nlmsg_cancel(skb, nlh);
76 return -EMSGSIZE;
76} 77}
77 78
78/* 79/*
@@ -89,9 +90,12 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
89 goto errout; 90 goto errout;
90 91
91 err = br_fill_ifinfo(skb, port, 0, 0, event, 0); 92 err = br_fill_ifinfo(skb, port, 0, 0, event, 0);
92 /* failure implies BUG in br_nlmsg_size() */ 93 if (err < 0) {
93 BUG_ON(err < 0); 94 /* -EMSGSIZE implies BUG in br_nlmsg_size() */
94 95 WARN_ON(err == -EMSGSIZE);
96 kfree_skb(skb);
97 goto errout;
98 }
95 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); 99 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
96errout: 100errout:
97 if (err < 0) 101 if (err < 0)