Skip to content

Commit 0c82fd9

Browse files
tobluxgregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5f8f84e commit 0c82fd9

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/misc/ibmasm/ibmasmfs.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,9 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
525525
if (*offset != 0)
526526
return 0;
527527

528-
buff = kzalloc (count + 1, GFP_KERNEL);
529-
if (!buff)
530-
return -ENOMEM;
531-
532-
533-
if (copy_from_user(buff, ubuff, count)) {
534-
kfree(buff);
535-
return -EFAULT;
536-
}
528+
buff = memdup_user_nul(ubuff, count);
529+
if (IS_ERR(buff))
530+
return PTR_ERR(buff);
537531

538532
value = simple_strtoul(buff, NULL, 10);
539533
writel(value, address);

0 commit comments

Comments
 (0)