Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thorsten Blum and committed by
Greg Kroah-Hartman
0c82fd96 5f8f84e2

+3 -9
+3 -9
drivers/misc/ibmasm/ibmasmfs.c
··· 525 525 if (*offset != 0) 526 526 return 0; 527 527 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); 537 531 538 532 value = simple_strtoul(buff, NULL, 10); 539 533 writel(value, address);