netdevsim: switch to memdup_user_nul()
Subsystems (4)
PATCH 1/1 netdevsim: switch to memdup_user_nul()
From: Wei Yongjun <[email protected]>
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Reported-by Hulk Robot <[email protected]>
Signed-off-by Wei Yongjun <[email protected]>
--- drivers/net/netdevsim/health.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/netdevsim/health.c +3 -8
@@ -235,15 +235,10 @@ static ssize_t nsim_dev_health_break_write(struct file *file,char *break_msg;int err; - break_msg =kmalloc (count +1 ,GFP_KERNEL ); -if (!break_msg) -return -ENOMEM ; + break_msg =memdup_user_nul (data, count); +if (IS_ERR (break_msg)) +return PTR_ERR (break_msg); -if (copy_from_user (break_msg, data, count)) { - err = -EFAULT ; - goto out; - } - break_msg[count] ='\0' ;if (break_msg[count -1 ] =='\n' ) break_msg[count -1 ] ='\0' ;
Quoted 7 lines · On Wed, 24 Mar 2021 14:42:20 +0000 'Wei Yongjun wrote:
From: Wei Yongjun <[email protected]>
Use
memdup_user_nul()helper instead of open-coding to simplify the code.Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>
Reviewed-by Jakub Kicinski <[email protected]>
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Wed, 24 Mar 2021 14:42:20 +0000 you wrote:
From: Wei Yongjun <[email protected]>
Use
memdup_user_nul()helper instead of open-coding to simplify the code.Reported-by Hulk Robot <[email protected]>Signed-off-by Wei Yongjun <[email protected]>[...]
Here is the summary with links:
- [net-next] netdevsim: switch to memdup_user_nul()
https://git.kernel.org/netdev/net-next/c/20fd4f421cf4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html