mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
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>
This commit is contained in:
parent
25a7de32c8
commit
183238ffb8
|
|
@ -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, ':');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user