iwlwifi: use kmemdup instead of kmalloc+memcpy
authorAndrei Epure <epure.andrei@gmail.com>
Sun, 10 Mar 2013 13:22:33 +0000 (15:22 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 20 Mar 2013 13:17:07 +0000 (14:17 +0100)
Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/iwlwifi/iwl-test.c

index efff2986b5b42fa4806177e1437f55d87b635e43..5cfd55b86ed3d33a779ab512bbc2df7c637f0f53 100644 (file)
@@ -272,7 +272,7 @@ static int iwl_test_fw_cmd(struct iwl_test *tst, struct nlattr **tb)
 
        reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
        skb = iwl_test_alloc_reply(tst, reply_len + 20);
-       reply_buf = kmalloc(reply_len, GFP_KERNEL);
+       reply_buf = kmemdup(&pkt->hdr, reply_len, GFP_KERNEL);
        if (!skb || !reply_buf) {
                kfree_skb(skb);
                kfree(reply_buf);
@@ -280,7 +280,6 @@ static int iwl_test_fw_cmd(struct iwl_test *tst, struct nlattr **tb)
        }
 
        /* The reply is in a page, that we cannot send to user space. */
-       memcpy(reply_buf, &(pkt->hdr), reply_len);
        iwl_free_resp(&cmd);
 
        if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,