diff options
-rw-r--r-- | net/wireless/wext.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index d6aaf65192e9..debf5191a128 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -1129,10 +1129,12 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev, | |||
1129 | { | 1129 | { |
1130 | struct ifinfomsg *r; | 1130 | struct ifinfomsg *r; |
1131 | struct nlmsghdr *nlh; | 1131 | struct nlmsghdr *nlh; |
1132 | unsigned char *b = skb_tail_pointer(skb); | ||
1133 | 1132 | ||
1134 | nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(*r)); | 1133 | nlh = nlmsg_put(skb, 0, 0, type, sizeof(*r), 0); |
1135 | r = NLMSG_DATA(nlh); | 1134 | if (nlh == NULL) |
1135 | return -EMSGSIZE; | ||
1136 | |||
1137 | r = nlmsg_data(nlh); | ||
1136 | r->ifi_family = AF_UNSPEC; | 1138 | r->ifi_family = AF_UNSPEC; |
1137 | r->__ifi_pad = 0; | 1139 | r->__ifi_pad = 0; |
1138 | r->ifi_type = dev->type; | 1140 | r->ifi_type = dev->type; |
@@ -1141,15 +1143,13 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev, | |||
1141 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ | 1143 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ |
1142 | 1144 | ||
1143 | /* Add the wireless events in the netlink packet */ | 1145 | /* Add the wireless events in the netlink packet */ |
1144 | RTA_PUT(skb, IFLA_WIRELESS, event_len, event); | 1146 | NLA_PUT(skb, IFLA_WIRELESS, event_len, event); |
1145 | 1147 | ||
1146 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 1148 | return nlmsg_end(skb, nlh); |
1147 | return skb->len; | ||
1148 | 1149 | ||
1149 | nlmsg_failure: | 1150 | nla_put_failure: |
1150 | rtattr_failure: | 1151 | nlmsg_cancel(skb, nlh); |
1151 | nlmsg_trim(skb, b); | 1152 | return -EMSGSIZE; |
1152 | return -1; | ||
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | /* ---------------------------------------------------------------- */ | 1155 | /* ---------------------------------------------------------------- */ |
@@ -1162,17 +1162,19 @@ rtattr_failure: | |||
1162 | static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len) | 1162 | static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len) |
1163 | { | 1163 | { |
1164 | struct sk_buff *skb; | 1164 | struct sk_buff *skb; |
1165 | int size = NLMSG_GOODSIZE; | 1165 | int err; |
1166 | 1166 | ||
1167 | skb = alloc_skb(size, GFP_ATOMIC); | 1167 | skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); |
1168 | if (!skb) | 1168 | if (!skb) |
1169 | return; | 1169 | return; |
1170 | 1170 | ||
1171 | if (rtnetlink_fill_iwinfo(skb, dev, RTM_NEWLINK, | 1171 | err = rtnetlink_fill_iwinfo(skb, dev, RTM_NEWLINK, event, event_len); |
1172 | event, event_len) < 0) { | 1172 | if (err < 0) { |
1173 | WARN_ON(err == -EMSGSIZE); | ||
1173 | kfree_skb(skb); | 1174 | kfree_skb(skb); |
1174 | return; | 1175 | return; |
1175 | } | 1176 | } |
1177 | |||
1176 | NETLINK_CB(skb).dst_group = RTNLGRP_LINK; | 1178 | NETLINK_CB(skb).dst_group = RTNLGRP_LINK; |
1177 | skb_queue_tail(&wireless_nlevent_queue, skb); | 1179 | skb_queue_tail(&wireless_nlevent_queue, skb); |
1178 | tasklet_schedule(&wireless_nlevent_tasklet); | 1180 | tasklet_schedule(&wireless_nlevent_tasklet); |