Search Linux Wireless

RE: [PATCH v2] mwifiex: replace kmalloc & memcpy sequence with kmemdup

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

 



Hi Joe,

Thanks for your comment.

> > Sequence of kmalloc/kzalloc and memcpy is replaced with
> > kmemdup.
> > diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
> []
> > @@ -1986,17 +1986,20 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv)
> >  		priv->curr_bcn_size = curr_bss->beacon_buf_size;
> >
> >  		kfree(priv->curr_bcn_buf);
> > -		priv->curr_bcn_buf = kzalloc(curr_bss->beacon_buf_size,
> > +
> > +		priv->curr_bcn_buf = kmemdup(curr_bss->beacon_buf,
> > +						curr_bss->beacon_buf_size,
> >  						GFP_KERNEL);
> 
> I think this block, because of the new else below it,
> isn't an improvement.

OK. Then we can just use kmalloc instead of kzalloc to save a buffer zeroing out in v3.

> 
> This kfree/kzalloc should probably just be krealloc with
> the memset unchanged.

The krealloc doesn't seem suitable here because krealloc does a useless memcpy.

Thanks,
Bing

> 
> >  		if (!priv->curr_bcn_buf) {
> >  			dev_err(priv->adapter->dev,
> >  					"failed to alloc curr_bcn_buf\n");
> >  			return;
> >  		}
> > +	} else {
> > +		memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
> > +			curr_bss->beacon_buf_size);
> >  	}
> >
> > -	memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
> > -		curr_bss->beacon_buf_size);
> >  	dev_dbg(priv->adapter->dev, "info: current beacon saved %d\n",
> >  		priv->curr_bcn_size);
> 

��.n��������+%������w��{.n�����{���zW����ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f



[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