Commit f0f53369 authored by Thorsten Blum's avatar Thorsten Blum Committed by Greg Kroah-Hartman

misc: fastrpc: Use memdup_user()

Switching to memdup_user() overwrites the allocated memory only once,
whereas kzalloc() followed by copy_from_user() initializes the allocated
memory to zero and then immediately overwrites it.

Fixes the following Coccinelle/coccicheck warning reported by
memdup_user.cocci:

	WARNING opportunity for memdup_user
Signed-off-by: default avatarThorsten Blum <thorsten.blum@toblux.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20240705075900.424100-2-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9d7eb234
...@@ -1259,17 +1259,12 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, ...@@ -1259,17 +1259,12 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
goto err; goto err;
} }
name = kzalloc(init.namelen, GFP_KERNEL); name = memdup_user(u64_to_user_ptr(init.name), init.namelen);
if (!name) { if (IS_ERR(name)) {
err = -ENOMEM; err = PTR_ERR(name);
goto err; 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) { if (!fl->cctx->remote_heap) {
err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
&fl->cctx->remote_heap); &fl->cctx->remote_heap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment