Skip to content

Commit

Permalink
media: siano: Use kmemdup instead of duplicating its function
Browse files Browse the repository at this point in the history
kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

This issue was detected with the help of coccinelle.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
CC: linux-kernel@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
  • Loading branch information
Wen Yang authored and Mauro Carvalho Chehab committed Dec 7, 2018
1 parent 00c30f4 commit 0f4bb10
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/media/usb/siano/smsusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,9 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size)
return -ENOENT;
}

phdr = kmalloc(size, GFP_KERNEL);
phdr = kmemdup(buffer, size, GFP_KERNEL);
if (!phdr)
return -ENOMEM;
memcpy(phdr, buffer, size);

pr_debug("sending %s(%d) size: %d\n",
smscore_translate_msg(phdr->msg_type), phdr->msg_type,
Expand Down

0 comments on commit 0f4bb10

Please sign in to comment.