diff mbox series

misc: fastrpc: Use memdup_user() rather than duplicating its implementation

Message ID e5d9404d-eb3b-4d35-a027-790229986cdf@web.de (mailing list archive)
State Superseded
Headers show
Series misc: fastrpc: Use memdup_user() rather than duplicating its implementation | expand

Commit Message

Markus Elfring Jan. 28, 2024, 2:35 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Jan 2024 15:17:03 +0100

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

Generated by: scripts/coccinelle/api/memdup_user.cocci

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/fastrpc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 1c6c62a7f7f5..83da6ad4e541 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1260,17 +1260,12 @@  static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
 		goto err;
 	}

-	name = kzalloc(init.namelen, GFP_KERNEL);
-	if (!name) {
-		err = -ENOMEM;
+	name = memdup_user(init.name, init.namelen);
+	if (IS_ERR(name) {
+		err = PTR_ERR(name);
 		goto err;
 	}

-	if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) {
-		err = -EFAULT;
-		goto err_name;
-	}
-
 	if (!fl->cctx->remote_heap) {
 		err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
 						&fl->cctx->remote_heap);