ibmasm: Replace kzalloc() + copy_from_user() with memdup_user_nul()
PATCH 1/1 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]>
--- drivers/misc/ibmasm/ibmasmfs.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/misc/ibmasm/ibmasmfs.c +3 -9
@@ -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);
Signature · 1 line
2.51.0