@@ -1070,15 +1070,19 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
1070
1070
struct mlx5hws_bwc_matcher * bwc_matcher = bwc_rule -> bwc_matcher ;
1071
1071
struct mlx5hws_bwc_complex_rule_hash_node * node , * old_node ;
1072
1072
struct rhashtable * refcount_hash ;
1073
- int i ;
1073
+ int ret , i ;
1074
1074
1075
1075
bwc_rule -> complex_hash_node = NULL ;
1076
1076
1077
1077
node = kzalloc (sizeof (* node ), GFP_KERNEL );
1078
1078
if (unlikely (!node ))
1079
1079
return - ENOMEM ;
1080
1080
1081
- node -> tag = ida_alloc (& bwc_matcher -> complex -> metadata_ida , GFP_KERNEL );
1081
+ ret = ida_alloc (& bwc_matcher -> complex -> metadata_ida , GFP_KERNEL );
1082
+ if (ret < 0 )
1083
+ goto err_free_node ;
1084
+ node -> tag = ret ;
1085
+
1082
1086
refcount_set (& node -> refcount , 1 );
1083
1087
1084
1088
/* Clear match buffer - turn off all the unrelated fields
@@ -1094,6 +1098,11 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
1094
1098
old_node = rhashtable_lookup_get_insert_fast (refcount_hash ,
1095
1099
& node -> hash_node ,
1096
1100
hws_refcount_hash );
1101
+ if (IS_ERR (old_node )) {
1102
+ ret = PTR_ERR (old_node );
1103
+ goto err_free_ida ;
1104
+ }
1105
+
1097
1106
if (old_node ) {
1098
1107
/* Rule with the same tag already exists - update refcount */
1099
1108
refcount_inc (& old_node -> refcount );
@@ -1112,6 +1121,12 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
1112
1121
1113
1122
bwc_rule -> complex_hash_node = node ;
1114
1123
return 0 ;
1124
+
1125
+ err_free_ida :
1126
+ ida_free (& bwc_matcher -> complex -> metadata_ida , node -> tag );
1127
+ err_free_node :
1128
+ kfree (node );
1129
+ return ret ;
1115
1130
}
1116
1131
1117
1132
static void
0 commit comments