aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox
diff options
context:
space:
mode:
authorHadar Hen Zion <hadarh@mellanox.com>2013-02-03 22:01:20 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-04 13:26:50 -0500
commit377d97393d93cca146937058986050a30857eec7 (patch)
tree31368627b703dd6f465f9cbddb55495cb492b156 /drivers/net/ethernet/mellanox
parent56db1c5f41c2ed0300ca570fea279a7c189c18fb (diff)
net/mlx4_en: Fix error propagation for ethtool helper function
Propagate return value of mlx4_en_ethtool_add_mac_rule_by_ipv4 in case of failure. Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c52
1 files changed, 34 insertions, 18 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 911d48876b32..3e993d5a1994 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -732,6 +732,7 @@ static int add_ip_rule(struct mlx4_en_priv *priv,
732 struct ethtool_rxnfc *cmd, 732 struct ethtool_rxnfc *cmd,
733 struct list_head *list_h) 733 struct list_head *list_h)
734{ 734{
735 int err;
735 struct mlx4_spec_list *spec_l2 = NULL; 736 struct mlx4_spec_list *spec_l2 = NULL;
736 struct mlx4_spec_list *spec_l3 = NULL; 737 struct mlx4_spec_list *spec_l3 = NULL;
737 struct ethtool_usrip4_spec *l3_mask = &cmd->fs.m_u.usr_ip4_spec; 738 struct ethtool_usrip4_spec *l3_mask = &cmd->fs.m_u.usr_ip4_spec;
@@ -740,14 +741,15 @@ static int add_ip_rule(struct mlx4_en_priv *priv,
740 spec_l2 = kzalloc(sizeof(*spec_l2), GFP_KERNEL); 741 spec_l2 = kzalloc(sizeof(*spec_l2), GFP_KERNEL);
741 if (!spec_l2 || !spec_l3) { 742 if (!spec_l2 || !spec_l3) {
742 en_err(priv, "Fail to alloc ethtool rule.\n"); 743 en_err(priv, "Fail to alloc ethtool rule.\n");
743 kfree(spec_l2); 744 err = -ENOMEM;
744 kfree(spec_l3); 745 goto free_spec;
745 return -ENOMEM;
746 } 746 }
747 747
748 mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, spec_l2, 748 err = mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, spec_l2,
749 cmd->fs.h_u. 749 cmd->fs.h_u.
750 usr_ip4_spec.ip4dst); 750 usr_ip4_spec.ip4dst);
751 if (err)
752 goto free_spec;
751 spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4; 753 spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4;
752 spec_l3->ipv4.src_ip = cmd->fs.h_u.usr_ip4_spec.ip4src; 754 spec_l3->ipv4.src_ip = cmd->fs.h_u.usr_ip4_spec.ip4src;
753 if (l3_mask->ip4src) 755 if (l3_mask->ip4src)
@@ -758,12 +760,18 @@ static int add_ip_rule(struct mlx4_en_priv *priv,
758 list_add_tail(&spec_l3->list, list_h); 760 list_add_tail(&spec_l3->list, list_h);
759 761
760 return 0; 762 return 0;
763
764free_spec:
765 kfree(spec_l2);
766 kfree(spec_l3);
767 return err;
761} 768}
762 769
763static int add_tcp_udp_rule(struct mlx4_en_priv *priv, 770static int add_tcp_udp_rule(struct mlx4_en_priv *priv,
764 struct ethtool_rxnfc *cmd, 771 struct ethtool_rxnfc *cmd,
765 struct list_head *list_h, int proto) 772 struct list_head *list_h, int proto)
766{ 773{
774 int err;
767 struct mlx4_spec_list *spec_l2 = NULL; 775 struct mlx4_spec_list *spec_l2 = NULL;
768 struct mlx4_spec_list *spec_l3 = NULL; 776 struct mlx4_spec_list *spec_l3 = NULL;
769 struct mlx4_spec_list *spec_l4 = NULL; 777 struct mlx4_spec_list *spec_l4 = NULL;
@@ -774,29 +782,31 @@ static int add_tcp_udp_rule(struct mlx4_en_priv *priv,
774 spec_l4 = kzalloc(sizeof(*spec_l4), GFP_KERNEL); 782 spec_l4 = kzalloc(sizeof(*spec_l4), GFP_KERNEL);
775 if (!spec_l2 || !spec_l3 || !spec_l4) { 783 if (!spec_l2 || !spec_l3 || !spec_l4) {
776 en_err(priv, "Fail to alloc ethtool rule.\n"); 784 en_err(priv, "Fail to alloc ethtool rule.\n");
777 kfree(spec_l2); 785 err = -ENOMEM;
778 kfree(spec_l3); 786 goto free_spec;
779 kfree(spec_l4);
780 return -ENOMEM;
781 } 787 }
782 788
783 spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4; 789 spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4;
784 790
785 if (proto == TCP_V4_FLOW) { 791 if (proto == TCP_V4_FLOW) {
786 mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, 792 err = mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h,
787 spec_l2, 793 spec_l2,
788 cmd->fs.h_u. 794 cmd->fs.h_u.
789 tcp_ip4_spec.ip4dst); 795 tcp_ip4_spec.ip4dst);
796 if (err)
797 goto free_spec;
790 spec_l4->id = MLX4_NET_TRANS_RULE_ID_TCP; 798 spec_l4->id = MLX4_NET_TRANS_RULE_ID_TCP;
791 spec_l3->ipv4.src_ip = cmd->fs.h_u.tcp_ip4_spec.ip4src; 799 spec_l3->ipv4.src_ip = cmd->fs.h_u.tcp_ip4_spec.ip4src;
792 spec_l3->ipv4.dst_ip = cmd->fs.h_u.tcp_ip4_spec.ip4dst; 800 spec_l3->ipv4.dst_ip = cmd->fs.h_u.tcp_ip4_spec.ip4dst;
793 spec_l4->tcp_udp.src_port = cmd->fs.h_u.tcp_ip4_spec.psrc; 801 spec_l4->tcp_udp.src_port = cmd->fs.h_u.tcp_ip4_spec.psrc;
794 spec_l4->tcp_udp.dst_port = cmd->fs.h_u.tcp_ip4_spec.pdst; 802 spec_l4->tcp_udp.dst_port = cmd->fs.h_u.tcp_ip4_spec.pdst;
795 } else { 803 } else {
796 mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, 804 err = mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h,
797 spec_l2, 805 spec_l2,
798 cmd->fs.h_u. 806 cmd->fs.h_u.
799 udp_ip4_spec.ip4dst); 807 udp_ip4_spec.ip4dst);
808 if (err)
809 goto free_spec;
800 spec_l4->id = MLX4_NET_TRANS_RULE_ID_UDP; 810 spec_l4->id = MLX4_NET_TRANS_RULE_ID_UDP;
801 spec_l3->ipv4.src_ip = cmd->fs.h_u.udp_ip4_spec.ip4src; 811 spec_l3->ipv4.src_ip = cmd->fs.h_u.udp_ip4_spec.ip4src;
802 spec_l3->ipv4.dst_ip = cmd->fs.h_u.udp_ip4_spec.ip4dst; 812 spec_l3->ipv4.dst_ip = cmd->fs.h_u.udp_ip4_spec.ip4dst;
@@ -818,6 +828,12 @@ static int add_tcp_udp_rule(struct mlx4_en_priv *priv,
818 list_add_tail(&spec_l4->list, list_h); 828 list_add_tail(&spec_l4->list, list_h);
819 829
820 return 0; 830 return 0;
831
832free_spec:
833 kfree(spec_l2);
834 kfree(spec_l3);
835 kfree(spec_l4);
836 return err;
821} 837}
822 838
823static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev, 839static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev,