提交 77ecb6fe 编写于 作者: L Laurent Navet 提交者: Greg Kroah-Hartman

staging: line6: Use kmemdup rather than duplicating its implementation

staging: line6: driver.c
 The semantic patch that makes this output is available
 in scripts/coccinelle/api/memdup.cocci.
Signed-off-by: NLaurent Navet <laurent.navet@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a3762902
...@@ -307,14 +307,13 @@ int line6_version_request_async(struct usb_line6 *line6) ...@@ -307,14 +307,13 @@ int line6_version_request_async(struct usb_line6 *line6)
char *buffer; char *buffer;
int retval; int retval;
buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC); buffer = kmemdup(line6_request_version,
sizeof(line6_request_version), GFP_ATOMIC);
if (buffer == NULL) { if (buffer == NULL) {
dev_err(line6->ifcdev, "Out of memory"); dev_err(line6->ifcdev, "Out of memory");
return -ENOMEM; return -ENOMEM;
} }
memcpy(buffer, line6_request_version, sizeof(line6_request_version));
retval = line6_send_raw_message_async(line6, buffer, retval = line6_send_raw_message_async(line6, buffer,
sizeof(line6_request_version)); sizeof(line6_request_version));
kfree(buffer); kfree(buffer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册