Skip to content

Commit

Permalink
staging: line6: Use kmemdup rather than duplicating its implementation
Browse files Browse the repository at this point in the history
staging: line6: driver.c
 The semantic patch that makes this output is available
 in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Laurent Navet authored and Greg Kroah-Hartman committed Jan 7, 2013
1 parent a376290 commit 77ecb6f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/staging/line6/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,13 @@ int line6_version_request_async(struct usb_line6 *line6)
char *buffer;
int retval;

buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC);
buffer = kmemdup(line6_request_version,
sizeof(line6_request_version), GFP_ATOMIC);
if (buffer == NULL) {
dev_err(line6->ifcdev, "Out of memory");
return -ENOMEM;
}

memcpy(buffer, line6_request_version, sizeof(line6_request_version));

retval = line6_send_raw_message_async(line6, buffer,
sizeof(line6_request_version));
kfree(buffer);
Expand Down

0 comments on commit 77ecb6f

Please sign in to comment.