Skip to content

Commit b21dddb

Browse files
committed
decnet: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error prone and make code hard to audit. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 24c410d commit b21dddb

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎net/decnet/dn_dev.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,13 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
695695
ifm->ifa_scope = ifa->ifa_scope;
696696
ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
697697

698-
if (ifa->ifa_address)
699-
NLA_PUT_LE16(skb, IFA_ADDRESS, ifa->ifa_address);
700-
if (ifa->ifa_local)
701-
NLA_PUT_LE16(skb, IFA_LOCAL, ifa->ifa_local);
702-
if (ifa->ifa_label[0])
703-
NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
704-
698+
if ((ifa->ifa_address &&
699+
nla_put_le16(skb, IFA_ADDRESS, ifa->ifa_address)) ||
700+
(ifa->ifa_local &&
701+
nla_put_le16(skb, IFA_LOCAL, ifa->ifa_local)) ||
702+
(ifa->ifa_label[0] &&
703+
nla_put_string(skb, IFA_LABEL, ifa->ifa_label)))
704+
goto nla_put_failure;
705705
return nlmsg_end(skb, nlh);
706706

707707
nla_put_failure:

‎net/decnet/dn_rules.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
204204
frh->src_len = r->src_len;
205205
frh->tos = 0;
206206

207-
if (r->dst_len)
208-
NLA_PUT_LE16(skb, FRA_DST, r->dst);
209-
if (r->src_len)
210-
NLA_PUT_LE16(skb, FRA_SRC, r->src);
211-
207+
if ((r->dst_len &&
208+
nla_put_le16(skb, FRA_DST, r->dst)) ||
209+
(r->src_len &&
210+
nla_put_le16(skb, FRA_SRC, r->src)))
211+
goto nla_put_failure;
212212
return 0;
213213

214214
nla_put_failure:

0 commit comments

Comments
 (0)