* [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
@ 2023-08-10 12:13 Ruan Jinjie
0 siblings, 0 replies; 3+ messages in thread
From: Ruan Jinjie @ 2023-08-10 12:13 UTC (permalink / raw)
To: arnd, gregkh, u.kleine-koenig, luca.ceresoli, jdelvare,
wsa+renesas, ruanjinjie, yuancan, linux-kernel
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
drivers/misc/eeprom/idt_89hpesx.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index 740c06382b83..433a4bc6b1c5 100644
--- 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, ':');
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
@ 2023-08-10 12:16 Ruan Jinjie
2023-08-11 15:28 ` Luca Ceresoli
0 siblings, 1 reply; 3+ messages in thread
From: Ruan Jinjie @ 2023-08-10 12:16 UTC (permalink / raw)
To: arnd, gregkh, u.kleine-koenig, luca.ceresoli, jdelvare,
wsa+renesas, yuancan, linux-kernel
Cc: ruanjinjie
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
drivers/misc/eeprom/idt_89hpesx.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index 740c06382b83..433a4bc6b1c5 100644
--- 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, ':');
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper
2023-08-10 12:16 [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper Ruan Jinjie
@ 2023-08-11 15:28 ` Luca Ceresoli
0 siblings, 0 replies; 3+ messages in thread
From: Luca Ceresoli @ 2023-08-11 15:28 UTC (permalink / raw)
To: Ruan Jinjie
Cc: arnd, gregkh, u.kleine-koenig, jdelvare, wsa+renesas, yuancan,
linux-kernel
On Thu, 10 Aug 2023 20:16:08 +0800
Ruan Jinjie <ruanjinjie@huawei.com> wrote:
> 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>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-11 15:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10 12:16 [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper Ruan Jinjie
2023-08-11 15:28 ` Luca Ceresoli
-- strict thread matches above, loose matches on Subject: below --
2023-08-10 12:13 Ruan Jinjie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox