Search Linux Wireless

Re: [PATCH] rt2x00: Remove duplicate deinitialization

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

 



Hi

> > @@ -509,16 +498,11 @@ static int rt2x00queue_alloc_rxskbs(struct rt2x00_dev *rt2x00dev,
> >  	for (i = 0; i < queue->limit; i++) {
> >  		skb = rt2x00queue_alloc_rxskb(rt2x00dev, &queue->entries[i]);
> >  		if (!skb)
> > -			goto exit;
> > +			return -ENOMEM;
> >  		queue->entries[i].skb = skb;
> >  	}
> >  
> >  	return 0;
> > -
> > -exit:
> > -	rt2x00queue_free_skbs(rt2x00dev, queue);
> > -
> > -	return -ENOMEM;
> >  }
> >  
> >  int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev)
> >   
> 
> 
> I find this last hunk of the patch a bit dubious. IMHO a function should 
> never rely on letting his caller do the right thing and clean up for it, 
> in case of failures; it should always clean up after itself. It is true 
> that in this case the caller will also attempt to clean up these 
> structures, but that doesn't mean that any potential future users of 
> such a function should be bothered with doing the same thing.

True but rt2x00queue_alloc_rxskbs and rt2x00queue_free_rxskbs are only
called once. And there isn't any reason why they should be called anywhere
else other then initialize() and uninitialize().

And this approach is the same as other allocation/free paths like in rt2x00pci/usb
and rt2x00lib.

Ivo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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