提交 31e0e328 编写于 作者: D David S. Miller

can: 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: NDavid S. Miller <davem@davemloft.net>
上级 4e24ffa4
...@@ -687,18 +687,19 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) ...@@ -687,18 +687,19 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
if (priv->do_get_state) if (priv->do_get_state)
priv->do_get_state(dev, &state); priv->do_get_state(dev, &state);
NLA_PUT_U32(skb, IFLA_CAN_STATE, state); if (nla_put_u32(skb, IFLA_CAN_STATE, state) ||
NLA_PUT(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm); nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) ||
NLA_PUT_U32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms); nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) ||
NLA_PUT(skb, IFLA_CAN_BITTIMING, nla_put(skb, IFLA_CAN_BITTIMING,
sizeof(priv->bittiming), &priv->bittiming); sizeof(priv->bittiming), &priv->bittiming) ||
NLA_PUT(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock); nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) ||
if (priv->do_get_berr_counter && !priv->do_get_berr_counter(dev, &bec)) (priv->do_get_berr_counter &&
NLA_PUT(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec); !priv->do_get_berr_counter(dev, &bec) &&
if (priv->bittiming_const) nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) ||
NLA_PUT(skb, IFLA_CAN_BITTIMING_CONST, (priv->bittiming_const &&
sizeof(*priv->bittiming_const), priv->bittiming_const); nla_put(skb, IFLA_CAN_BITTIMING_CONST,
sizeof(*priv->bittiming_const), priv->bittiming_const)))
goto nla_put_failure;
return 0; return 0;
nla_put_failure: nla_put_failure:
...@@ -714,9 +715,9 @@ static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev) ...@@ -714,9 +715,9 @@ static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev)
{ {
struct can_priv *priv = netdev_priv(dev); struct can_priv *priv = netdev_priv(dev);
NLA_PUT(skb, IFLA_INFO_XSTATS, if (nla_put(skb, IFLA_INFO_XSTATS,
sizeof(priv->can_stats), &priv->can_stats); sizeof(priv->can_stats), &priv->can_stats))
goto nla_put_failure;
return 0; return 0;
nla_put_failure: nla_put_failure:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册