Search Linux Wireless

Re: [PATCH] net/wireless/nl80211.c: fix endless Netlink callback loop.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >>       int idx = 0;
> >>       int start = cb->args[0];
> >>       struct cfg80211_registered_device *dev;
> >>
> >>       mutex_lock(&cfg80211_drv_mutex);
> >>       list_for_each_entry(dev, &cfg80211_drv_list, list) {
> >> -             if (++idx < start)
> >> +             if (++idx <= start)
> >>                       continue;
> >>               if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid,
> >>                                      cb->nlh->nlmsg_seq, NLM_F_MULTI,
> >> -                                    dev) < 0)
> >> +                                    dev) < 0) {
> >> +                     idx--;
> >>                       break;
> >> +             }
> >
> > I see much of the problem stemming from incrementing 'idx' at the
> > beginning of the loop, can't we just move it to the end?
> 
> idx still needs to be incremented in the 'continue' case, so that
> alone wouldn't help. I'm not sure if there is a way to make this look
> more intuitive?

Good point. The only ways I can come up with add further to the already
quite deep indentation:

list_for_each_entry(...) {
	if (idx > start)
		if (nl80211_send_wiphy(...) < 0)
			break;
	idx++;
}

or hide the call into an if ():

list_for_each_entry(...) {
	if (idx > start && nl80211_send_wiphy(...))
		break;
	idx++;
}

Not sure. I guess the code isn't touched often so your patch is fine.

johannes

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux