summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-09-05 12:32:44 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-09-06 16:00:54 +0200
commit0c82fd9609a1e4bf1db84b0fd56bc3b2773da179 (patch)
tree6870c47c6fe6f387e76199908e3344585b3b11d2
parent5f8f84e286f11af4c954c14a57daffc80a1c3510 (diff)
ibmasm: Replace kzalloc() + copy_from_user() with memdup_user_nul()
Replace kzalloc() followed by copy_from_user() with memdup_user_nul() to improve and simplify remote_settings_file_write(). No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250905103247.423840-2-thorsten.blum@linux.dev Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index c44de892a61e..2d5c1df82732 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -525,15 +525,9 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
if (*offset != 0)
return 0;
- buff = kzalloc (count + 1, GFP_KERNEL);
- if (!buff)
- return -ENOMEM;
-
-
- if (copy_from_user(buff, ubuff, count)) {
- kfree(buff);
- return -EFAULT;
- }
+ buff = memdup_user_nul(ubuff, count);
+ if (IS_ERR(buff))
+ return PTR_ERR(buff);
value = simple_strtoul(buff, NULL, 10);
writel(value, address);