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.

block: floppy: Replace kmalloc() + copy_from_user() with memdup_user()

Replace kmalloc() followed by copy_from_user() with memdup_user() to
improve and simplify raw_cmd_copyin().

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Thorsten Blum and committed by
Jens Axboe
6214cadd 199c9a8d

+3 -6
+3 -6
drivers/block/floppy.c
··· 3090 3090 *rcmd = NULL; 3091 3091 3092 3092 loop: 3093 - ptr = kmalloc(sizeof(struct floppy_raw_cmd), GFP_KERNEL); 3094 - if (!ptr) 3095 - return -ENOMEM; 3093 + ptr = memdup_user(param, sizeof(*ptr)); 3094 + if (IS_ERR(ptr)) 3095 + return PTR_ERR(ptr); 3096 3096 *rcmd = ptr; 3097 - ret = copy_from_user(ptr, param, sizeof(*ptr)); 3098 3097 ptr->next = NULL; 3099 3098 ptr->buffer_length = 0; 3100 3099 ptr->kernel_data = NULL; 3101 - if (ret) 3102 - return -EFAULT; 3103 3100 param += sizeof(struct floppy_raw_cmd); 3104 3101 if (ptr->cmd_count > FD_RAW_CMD_FULLSIZE) 3105 3102 return -EINVAL;