diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index c3434e902445..63d3b0ac43fb 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -50,13 +50,14 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, if (tb[TCA_PEDIT_PARMS] == NULL) return -EINVAL; parm = nla_data(tb[TCA_PEDIT_PARMS]); + if (!parm->nkeys) + return -EINVAL; + ksize = parm->nkeys * sizeof(struct tc_pedit_key); if (nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm) + ksize) return -EINVAL; if (!tcf_hash_check(parm->index, a, bind)) { - if (!parm->nkeys) - return -EINVAL; ret = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, false); if (ret)