@@ -109,16 +109,18 @@ static int tcf_pedit_key_ex_dump(struct sk_buff *skb,
109
109
{
110
110
struct nlattr * keys_start = nla_nest_start (skb , TCA_PEDIT_KEYS_EX );
111
111
112
+ if (!keys_start )
113
+ goto nla_failure ;
112
114
for (; n > 0 ; n -- ) {
113
115
struct nlattr * key_start ;
114
116
115
117
key_start = nla_nest_start (skb , TCA_PEDIT_KEY_EX );
118
+ if (!key_start )
119
+ goto nla_failure ;
116
120
117
121
if (nla_put_u16 (skb , TCA_PEDIT_KEY_EX_HTYPE , keys_ex -> htype ) ||
118
- nla_put_u16 (skb , TCA_PEDIT_KEY_EX_CMD , keys_ex -> cmd )) {
119
- nlmsg_trim (skb , keys_start );
120
- return - EINVAL ;
121
- }
122
+ nla_put_u16 (skb , TCA_PEDIT_KEY_EX_CMD , keys_ex -> cmd ))
123
+ goto nla_failure ;
122
124
123
125
nla_nest_end (skb , key_start );
124
126
@@ -128,6 +130,9 @@ static int tcf_pedit_key_ex_dump(struct sk_buff *skb,
128
130
nla_nest_end (skb , keys_start );
129
131
130
132
return 0 ;
133
+ nla_failure :
134
+ nla_nest_cancel (skb , keys_start );
135
+ return - EINVAL ;
131
136
}
132
137
133
138
static int tcf_pedit_init (struct net * net , struct nlattr * nla ,
@@ -395,7 +400,10 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
395
400
opt -> bindcnt = p -> tcf_bindcnt - bind ;
396
401
397
402
if (p -> tcfp_keys_ex ) {
398
- tcf_pedit_key_ex_dump (skb , p -> tcfp_keys_ex , p -> tcfp_nkeys );
403
+ if (tcf_pedit_key_ex_dump (skb ,
404
+ p -> tcfp_keys_ex ,
405
+ p -> tcfp_nkeys ))
406
+ goto nla_put_failure ;
399
407
400
408
if (nla_put (skb , TCA_PEDIT_PARMS_EX , s , opt ))
401
409
goto nla_put_failure ;
0 commit comments