diff options
author | David S. Miller <davem@davemloft.net> | 2012-04-01 20:21:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-02 04:33:42 -0400 |
commit | 31e0e328899af2ee677dbede5b236eb59b762444 (patch) | |
tree | 448b655ec6a10eaa15610b1442a4bfe8e10a9e84 /drivers/net/can/dev.c | |
parent | 4e24ffa4d9fed762147c954755f8cb124e85740a (diff) |
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: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can/dev.c')
-rw-r--r-- | drivers/net/can/dev.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index c5fe3a3db8c9..f03d7a481a80 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c | |||
@@ -687,18 +687,19 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) | |||
687 | 687 | ||
688 | if (priv->do_get_state) | 688 | if (priv->do_get_state) |
689 | priv->do_get_state(dev, &state); | 689 | priv->do_get_state(dev, &state); |
690 | NLA_PUT_U32(skb, IFLA_CAN_STATE, state); | 690 | if (nla_put_u32(skb, IFLA_CAN_STATE, state) || |
691 | NLA_PUT(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm); | 691 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || |
692 | NLA_PUT_U32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms); | 692 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || |
693 | NLA_PUT(skb, IFLA_CAN_BITTIMING, | 693 | nla_put(skb, IFLA_CAN_BITTIMING, |
694 | sizeof(priv->bittiming), &priv->bittiming); | 694 | sizeof(priv->bittiming), &priv->bittiming) || |
695 | NLA_PUT(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock); | 695 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || |
696 | if (priv->do_get_berr_counter && !priv->do_get_berr_counter(dev, &bec)) | 696 | (priv->do_get_berr_counter && |
697 | NLA_PUT(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec); | 697 | !priv->do_get_berr_counter(dev, &bec) && |
698 | if (priv->bittiming_const) | 698 | nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) || |
699 | NLA_PUT(skb, IFLA_CAN_BITTIMING_CONST, | 699 | (priv->bittiming_const && |
700 | sizeof(*priv->bittiming_const), priv->bittiming_const); | 700 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, |
701 | 701 | sizeof(*priv->bittiming_const), priv->bittiming_const))) | |
702 | goto nla_put_failure; | ||
702 | return 0; | 703 | return 0; |
703 | 704 | ||
704 | nla_put_failure: | 705 | nla_put_failure: |
@@ -714,9 +715,9 @@ static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev) | |||
714 | { | 715 | { |
715 | struct can_priv *priv = netdev_priv(dev); | 716 | struct can_priv *priv = netdev_priv(dev); |
716 | 717 | ||
717 | NLA_PUT(skb, IFLA_INFO_XSTATS, | 718 | if (nla_put(skb, IFLA_INFO_XSTATS, |
718 | sizeof(priv->can_stats), &priv->can_stats); | 719 | sizeof(priv->can_stats), &priv->can_stats)) |
719 | 720 | goto nla_put_failure; | |
720 | return 0; | 721 | return 0; |
721 | 722 | ||
722 | nla_put_failure: | 723 | nla_put_failure: |