]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Staging: wilc1000: wilc_msgqueue: Use kmemdup instead of kmalloc and memcpy
authorShraddha Barke <shraddha.6596@gmail.com>
Sun, 11 Oct 2015 16:31:37 +0000 (22:01 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 04:01:28 +0000 (21:01 -0700)
Replace kmalloc and memcpy with kmemdup.
Problem found using coccicheck

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_msgqueue.c

index d5ebd6d08db771223a5f2702d9a4b9130ff6abcc..b13809a4b556a41a78172ce2ba6b52666d50c969 100644 (file)
@@ -80,12 +80,12 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
                return -ENOMEM;
        pstrMessage->u32Length = u32SendBufferSize;
        pstrMessage->pstrNext = NULL;
-       pstrMessage->pvBuffer = kmalloc(u32SendBufferSize, GFP_ATOMIC);
+       pstrMessage->pvBuffer = kmemdup(pvSendBuffer, u32SendBufferSize,
+                                       GFP_ATOMIC);
        if (!pstrMessage->pvBuffer) {
                result = -ENOMEM;
                goto ERRORHANDLER;
        }
-       memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);
 
        /* add it to the message queue */
        if (!pHandle->pstrMessageList) {