@@ -310,7 +310,10 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)
310310 /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
311311 x = q -> tail -> next ;
312312 slot = & q -> slots [x ];
313- q -> tail -> next = slot -> next ;
313+ if (slot -> next == x )
314+ q -> tail = NULL ; /* no more active slots */
315+ else
316+ q -> tail -> next = slot -> next ;
314317 q -> ht [slot -> hash ] = SFQ_EMPTY_SLOT ;
315318 goto drop ;
316319 }
@@ -653,6 +656,14 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,
653656 NL_SET_ERR_MSG_MOD (extack , "invalid quantum" );
654657 return - EINVAL ;
655658 }
659+
660+ if (ctl -> perturb_period < 0 ||
661+ ctl -> perturb_period > INT_MAX / HZ ) {
662+ NL_SET_ERR_MSG_MOD (extack , "invalid perturb period" );
663+ return - EINVAL ;
664+ }
665+ perturb_period = ctl -> perturb_period * HZ ;
666+
656667 if (ctl_v1 && !red_check_params (ctl_v1 -> qth_min , ctl_v1 -> qth_max ,
657668 ctl_v1 -> Wlog , ctl_v1 -> Scell_log , NULL ))
658669 return - EINVAL ;
@@ -669,14 +680,12 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,
669680 headdrop = q -> headdrop ;
670681 maxdepth = q -> maxdepth ;
671682 maxflows = q -> maxflows ;
672- perturb_period = q -> perturb_period ;
673683 quantum = q -> quantum ;
674684 flags = q -> flags ;
675685
676686 /* update and validate configuration */
677687 if (ctl -> quantum )
678688 quantum = ctl -> quantum ;
679- perturb_period = ctl -> perturb_period * HZ ;
680689 if (ctl -> flows )
681690 maxflows = min_t (u32 , ctl -> flows , SFQ_MAX_FLOWS );
682691 if (ctl -> divisor ) {
0 commit comments