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.

xen/privcmd: Use memdup_array_user() in alloc_ioreq()

* The function “memdup_array_user” was added with the
commit 313ebe47d75558511aa1237b6e35c663b5c0ec6f ("string.h: add
array-wrappers for (v)memdup_user()").
Thus use it accordingly.

This issue was detected by using the Coccinelle software.

* Delete a label which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/41e333f7-1f3a-41b6-a121-a3c0ae54e36f@web.de
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Markus Elfring and committed by
Juergen Gross
b2c52b8c 3693bb44

+5 -10
+5 -10
drivers/xen/privcmd.c
··· 1223 1223 kioreq->ioreq = (struct ioreq *)(page_to_virt(pages[0])); 1224 1224 mmap_write_unlock(mm); 1225 1225 1226 - size = sizeof(*ports) * kioreq->vcpus; 1227 - ports = kzalloc(size, GFP_KERNEL); 1228 - if (!ports) { 1229 - ret = -ENOMEM; 1226 + ports = memdup_array_user(u64_to_user_ptr(ioeventfd->ports), 1227 + kioreq->vcpus, sizeof(*ports)); 1228 + if (IS_ERR(ports)) { 1229 + ret = PTR_ERR(ports); 1230 1230 goto error_kfree; 1231 - } 1232 - 1233 - if (copy_from_user(ports, u64_to_user_ptr(ioeventfd->ports), size)) { 1234 - ret = -EFAULT; 1235 - goto error_kfree_ports; 1236 1231 } 1237 1232 1238 1233 for (i = 0; i < kioreq->vcpus; i++) { ··· 1251 1256 error_unbind: 1252 1257 while (--i >= 0) 1253 1258 unbind_from_irqhandler(irq_from_evtchn(ports[i]), &kioreq->ports[i]); 1254 - error_kfree_ports: 1259 + 1255 1260 kfree(ports); 1256 1261 error_kfree: 1257 1262 kfree(kioreq);