projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
25a7de3
)
misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
author
Ruan Jinjie
<ruanjinjie@huawei.com>
Thu, 10 Aug 2023 12:16:08 +0000
(20:16 +0800)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 19:38:49 +0000
(21:38 +0200)
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link:
https://lore.kernel.org/r/20230810121608.2110328-1-ruanjinjie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/eeprom/idt_89hpesx.c
patch
|
blob
|
history
diff --git
a/drivers/misc/eeprom/idt_89hpesx.c
b/drivers/misc/eeprom/idt_89hpesx.c
index 740c06382b8347f898a9e6424b9ce32e0438074f..433a4bc6b1c595ed7cef3f698c98bf2cd4faa82c 100644
(file)
--- a/
drivers/misc/eeprom/idt_89hpesx.c
+++ b/
drivers/misc/eeprom/idt_89hpesx.c
@@
-913,15
+913,9
@@
static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
return 0;
/* Copy data from User-space */
- buf = kmalloc(count + 1, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- if (copy_from_user(buf, ubuf, count)) {
- ret = -EFAULT;
- goto free_buf;
- }
- buf[count] = 0;
+ buf = memdup_user_nul(ubuf, count);
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
/* Find position of colon in the buffer */
colon_ch = strnchr(buf, count, ':');