Search Linux Wireless

Re: [PATCH RFC] cfg80211: Add ies_allocated check before copying ies

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

 



On Sun, 2009-04-26 at 10:40 +0200, Michael Buesch wrote:

> > I think it should simply be:
> > 
> > >  			size_t ielen = res->pub.len_information_elements;
> > >  
> > > -			if (ksize(found) >= used + ielen) {
> > > +			if (!found->ies_allocated && ksize(found) >= used + ielen) {
> > >  				memcpy(found->pub.information_elements,
> > >  				       res->pub.information_elements, ielen);
> > >  				found->pub.len_information_elements = ielen;
> > > 
> > 
> > so that the else branch gets a chance to reallocate if necessary, would
> > you agree?
> 
> Yeah I first also considered this option, but I thought that the code likes to
> prefer putting the stuff into the "found" tail, if it fits.
> But yes, your fix is perfectly fine. If it was allocated once, it will always be
> allocated (and grown) from then on.
> It won't shrink the buffer anymore for future ies that are smaller, but I guess that's OK.

Ah, yes, but then the correct fix would be to kfree the allocated IEs
and use the old buffer again, not discard the data :) I don't think it's
worth bothering, the entire structures are usually freed fairly quickly
anyway. Do you want to redo the patch or would you prefer if I sent it?

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