Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Thorsten Blum <thorsten.blum@toblux.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20240705075900.424100-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thorsten Blum and committed by
Greg Kroah-Hartman
f0f53369 9d7eb234

+3 -8
+3 -8
drivers/misc/fastrpc.c
··· 1259 1259 goto err; 1260 1260 } 1261 1261 1262 - name = kzalloc(init.namelen, GFP_KERNEL); 1263 - if (!name) { 1264 - err = -ENOMEM; 1262 + name = memdup_user(u64_to_user_ptr(init.name), init.namelen); 1263 + if (IS_ERR(name)) { 1264 + err = PTR_ERR(name); 1265 1265 goto err; 1266 - } 1267 - 1268 - if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) { 1269 - err = -EFAULT; 1270 - goto err_name; 1271 1266 } 1272 1267 1273 1268 if (!fl->cctx->remote_heap) {