All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] netdevsim: switch to memdup_user_nul()
@ 2021-03-24 14:42 'Wei Yongjun
  2021-03-24 21:51 ` Jakub Kicinski
  2021-03-24 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: 'Wei Yongjun @ 2021-03-24 14:42 UTC (permalink / raw)
  To: weiyongjun1, Jakub Kicinski, Jiri Pirko
  Cc: netdev, kernel-janitors, Hulk Robot

From: Wei Yongjun <weiyongjun1@huawei.com>

Use memdup_user_nul() helper instead of open-coding to
simplify the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/netdevsim/health.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 21e2974660e7..04aebdf85747 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -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';
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] netdevsim: switch to memdup_user_nul()
  2021-03-24 14:42 [PATCH net-next] netdevsim: switch to memdup_user_nul() 'Wei Yongjun
@ 2021-03-24 21:51 ` Jakub Kicinski
  2021-03-24 23:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-03-24 21:51 UTC (permalink / raw)
  To: 'Wei Yongjun; +Cc: Jiri Pirko, netdev, kernel-janitors, Hulk Robot

On Wed, 24 Mar 2021 14:42:20 +0000 'Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> Use memdup_user_nul() helper instead of open-coding to
> simplify the code.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] netdevsim: switch to memdup_user_nul()
  2021-03-24 14:42 [PATCH net-next] netdevsim: switch to memdup_user_nul() 'Wei Yongjun
  2021-03-24 21:51 ` Jakub Kicinski
@ 2021-03-24 23:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-24 23:30 UTC (permalink / raw)
  To: 'Wei Yongjun; +Cc: kuba, jiri, netdev, kernel-janitors, hulkci

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed, 24 Mar 2021 14:42:20 +0000 you wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> Use memdup_user_nul() helper instead of open-coding to
> simplify the code.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> 
> [...]

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-24 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 14:42 [PATCH net-next] netdevsim: switch to memdup_user_nul() 'Wei Yongjun
2021-03-24 21:51 ` Jakub Kicinski
2021-03-24 23:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.