aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Fastabend <john.r.fastabend@intel.com>2012-02-09 22:19:35 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-03-02 21:11:24 -0500
commit89d27a3c0ad7d5f2ce9ece055b3c7c619dc42f6c (patch)
tree26f7026391dc63d31cf94ed33730bc2fc1ab25f6
parent6f66342c1ecd59467d4579176dd81a4e837a06ef (diff)
ixgbe: dcb: check setup_tc return codes
dcb netlink code calls setup_tc to init hardware traffic classes to use for DCB. At some call sites the return values are not checked for errors and in one case may return -EINVAL back to the net/dcbnl.c caller which is expecting a u8. This fixes some smatch hits and although failures are never seen in practive its best to check return codes. Reported-by: Dan Carenter <dan.carpenter@oracle.com> Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
index 79a92fe987b9..95e5d11bb555 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c
@@ -111,7 +111,7 @@ static u8 ixgbe_dcbnl_get_state(struct net_device *netdev)
111 111
112static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) 112static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
113{ 113{
114 u8 err = 0; 114 int err = 0;
115 u8 prio_tc[MAX_USER_PRIORITY] = {0}; 115 u8 prio_tc[MAX_USER_PRIORITY] = {0};
116 int i; 116 int i;
117 struct ixgbe_adapter *adapter = netdev_priv(netdev); 117 struct ixgbe_adapter *adapter = netdev_priv(netdev);
@@ -122,7 +122,7 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
122 122
123 /* verify there is something to do, if not then exit */ 123 /* verify there is something to do, if not then exit */
124 if (!!state != !(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) 124 if (!!state != !(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
125 return err; 125 goto out;
126 126
127 if (state > 0) { 127 if (state > 0) {
128 err = ixgbe_setup_tc(netdev, adapter->dcb_cfg.num_tcs.pg_tcs); 128 err = ixgbe_setup_tc(netdev, adapter->dcb_cfg.num_tcs.pg_tcs);
@@ -131,10 +131,14 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
131 err = ixgbe_setup_tc(netdev, 0); 131 err = ixgbe_setup_tc(netdev, 0);
132 } 132 }
133 133
134 if (err)
135 goto out;
136
134 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) 137 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
135 netdev_set_prio_tc_map(netdev, i, prio_tc[i]); 138 netdev_set_prio_tc_map(netdev, i, prio_tc[i]);
136 139
137 return err; 140out:
141 return err ? 1 : 0;
138} 142}
139 143
140static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev, 144static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev,
@@ -581,7 +585,7 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
581{ 585{
582 struct ixgbe_adapter *adapter = netdev_priv(dev); 586 struct ixgbe_adapter *adapter = netdev_priv(dev);
583 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN; 587 int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;
584 int i; 588 int i, err = 0;
585 __u8 max_tc = 0; 589 __u8 max_tc = 0;
586 590
587 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) 591 if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
@@ -608,12 +612,17 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,
608 return -EINVAL; 612 return -EINVAL;
609 613
610 if (max_tc != netdev_get_num_tc(dev)) 614 if (max_tc != netdev_get_num_tc(dev))
611 ixgbe_setup_tc(dev, max_tc); 615 err = ixgbe_setup_tc(dev, max_tc);
616
617 if (err)
618 goto err_out;
612 619
613 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) 620 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
614 netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]); 621 netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]);
615 622
616 return ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame); 623 err = ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame);
624err_out:
625 return err;
617} 626}
618 627
619static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev, 628static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev,
@@ -726,6 +735,7 @@ static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
726 struct ixgbe_adapter *adapter = netdev_priv(dev); 735 struct ixgbe_adapter *adapter = netdev_priv(dev);
727 struct ieee_ets ets = {0}; 736 struct ieee_ets ets = {0};
728 struct ieee_pfc pfc = {0}; 737 struct ieee_pfc pfc = {0};
738 int err = 0;
729 739
730 /* no support for LLD_MANAGED modes or CEE+IEEE */ 740 /* no support for LLD_MANAGED modes or CEE+IEEE */
731 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || 741 if ((mode & DCB_CAP_DCBX_LLD_MANAGED) ||
@@ -756,10 +766,10 @@ static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode)
756 */ 766 */
757 ixgbe_dcbnl_ieee_setets(dev, &ets); 767 ixgbe_dcbnl_ieee_setets(dev, &ets);
758 ixgbe_dcbnl_ieee_setpfc(dev, &pfc); 768 ixgbe_dcbnl_ieee_setpfc(dev, &pfc);
759 ixgbe_setup_tc(dev, 0); 769 err = ixgbe_setup_tc(dev, 0);
760 } 770 }
761 771
762 return 0; 772 return err ? 1 : 0;
763} 773}
764 774
765const struct dcbnl_rtnl_ops dcbnl_ops = { 775const struct dcbnl_rtnl_ops dcbnl_ops = {