Skip to content

Commit 81e7916

Browse files
wr0112358gregkh
authored andcommitted
drop_monitor: add missing call to genlmsg_end
[ Upstream commit 4200462d88f47f3759bdf4705f87e207b0f5b2e4 ] Update nlmsg_len field with genlmsg_end to enable userspace processing using nlmsg_next helper. Also adds error handling. Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1ff0308 commit 81e7916

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

net/core/drop_monitor.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,39 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
8080
struct nlattr *nla;
8181
struct sk_buff *skb;
8282
unsigned long flags;
83+
void *msg_header;
8384

8485
al = sizeof(struct net_dm_alert_msg);
8586
al += dm_hit_limit * sizeof(struct net_dm_drop_point);
8687
al += sizeof(struct nlattr);
8788

8889
skb = genlmsg_new(al, GFP_KERNEL);
8990

90-
if (skb) {
91-
genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
92-
0, NET_DM_CMD_ALERT);
93-
nla = nla_reserve(skb, NLA_UNSPEC,
94-
sizeof(struct net_dm_alert_msg));
95-
msg = nla_data(nla);
96-
memset(msg, 0, al);
97-
} else {
98-
mod_timer(&data->send_timer, jiffies + HZ / 10);
91+
if (!skb)
92+
goto err;
93+
94+
msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
95+
0, NET_DM_CMD_ALERT);
96+
if (!msg_header) {
97+
nlmsg_free(skb);
98+
skb = NULL;
99+
goto err;
100+
}
101+
nla = nla_reserve(skb, NLA_UNSPEC,
102+
sizeof(struct net_dm_alert_msg));
103+
if (!nla) {
104+
nlmsg_free(skb);
105+
skb = NULL;
106+
goto err;
99107
}
108+
msg = nla_data(nla);
109+
memset(msg, 0, al);
110+
genlmsg_end(skb, msg_header);
111+
goto out;
100112

113+
err:
114+
mod_timer(&data->send_timer, jiffies + HZ / 10);
115+
out:
101116
spin_lock_irqsave(&data->lock, flags);
102117
swap(data->skb, skb);
103118
spin_unlock_irqrestore(&data->lock, flags);

0 commit comments

Comments
 (0)