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]

 



On Thu, 2011-08-25 at 12:37 -0700, Bing Zhao wrote:
> 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.

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

>  		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);


--
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