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