Skip to content

Commit

Permalink
net:liquidio: use kmemdup
Browse files Browse the repository at this point in the history
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.

Signed-off-by: Muhammad Falak R Wani <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mfrw authored and davem330 committed May 20, 2016
1 parent e27f4a9 commit 7c54277
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/ethernet/cavium/liquidio/octeon_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,10 @@ int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s",
h->version);

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

memcpy(buffer, data, size);

p = buffer + sizeof(struct octeon_firmware_file_header);

/* load all images */
Expand Down

0 comments on commit 7c54277

Please sign in to comment.