diff options
-rw-r--r-- | drivers/block/floppy.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 8f5565bf34cd..fa9bb742df6e 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -3067,7 +3067,10 @@ static int raw_cmd_copyout(int cmd, void __user *param, | |||
3067 | int ret; | 3067 | int ret; |
3068 | 3068 | ||
3069 | while (ptr) { | 3069 | while (ptr) { |
3070 | ret = copy_to_user(param, ptr, sizeof(*ptr)); | 3070 | struct floppy_raw_cmd cmd = *ptr; |
3071 | cmd.next = NULL; | ||
3072 | cmd.kernel_data = NULL; | ||
3073 | ret = copy_to_user(param, &cmd, sizeof(cmd)); | ||
3071 | if (ret) | 3074 | if (ret) |
3072 | return -EFAULT; | 3075 | return -EFAULT; |
3073 | param += sizeof(struct floppy_raw_cmd); | 3076 | param += sizeof(struct floppy_raw_cmd); |
@@ -3121,10 +3124,11 @@ loop: | |||
3121 | return -ENOMEM; | 3124 | return -ENOMEM; |
3122 | *rcmd = ptr; | 3125 | *rcmd = ptr; |
3123 | ret = copy_from_user(ptr, param, sizeof(*ptr)); | 3126 | ret = copy_from_user(ptr, param, sizeof(*ptr)); |
3124 | if (ret) | ||
3125 | return -EFAULT; | ||
3126 | ptr->next = NULL; | 3127 | ptr->next = NULL; |
3127 | ptr->buffer_length = 0; | 3128 | ptr->buffer_length = 0; |
3129 | ptr->kernel_data = NULL; | ||
3130 | if (ret) | ||
3131 | return -EFAULT; | ||
3128 | param += sizeof(struct floppy_raw_cmd); | 3132 | param += sizeof(struct floppy_raw_cmd); |
3129 | if (ptr->cmd_count > 33) | 3133 | if (ptr->cmd_count > 33) |
3130 | /* the command may now also take up the space | 3134 | /* the command may now also take up the space |
@@ -3140,7 +3144,6 @@ loop: | |||
3140 | for (i = 0; i < 16; i++) | 3144 | for (i = 0; i < 16; i++) |
3141 | ptr->reply[i] = 0; | 3145 | ptr->reply[i] = 0; |
3142 | ptr->resultcode = 0; | 3146 | ptr->resultcode = 0; |
3143 | ptr->kernel_data = NULL; | ||
3144 | 3147 | ||
3145 | if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { | 3148 | if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { |
3146 | if (ptr->length <= 0) | 3149 | if (ptr->length <= 0) |