@@ -129,10 +129,9 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
129
129
if (!nvme_ctrl_sgl_supported (ctrl ))
130
130
dev_warn_once (ctrl -> device , "using unchecked data buffer\n" );
131
131
if (has_metadata ) {
132
- if (!supports_metadata ) {
133
- ret = - EINVAL ;
134
- goto out ;
135
- }
132
+ if (!supports_metadata )
133
+ return - EINVAL ;
134
+
136
135
if (!nvme_ctrl_meta_sgl_supported (ctrl ))
137
136
dev_warn_once (ctrl -> device ,
138
137
"using unchecked metadata buffer\n" );
@@ -142,15 +141,14 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
142
141
struct iov_iter iter ;
143
142
144
143
/* fixedbufs is only for non-vectored io */
145
- if (flags & NVME_IOCTL_VEC ) {
146
- ret = - EINVAL ;
147
- goto out ;
148
- }
144
+ if (flags & NVME_IOCTL_VEC )
145
+ return - EINVAL ;
146
+
149
147
ret = io_uring_cmd_import_fixed (ubuffer , bufflen ,
150
148
rq_data_dir (req ), & iter , ioucmd ,
151
149
iou_issue_flags );
152
150
if (ret < 0 )
153
- goto out ;
151
+ return ret ;
154
152
ret = blk_rq_map_user_iov (q , req , NULL , & iter , GFP_KERNEL );
155
153
} else {
156
154
ret = blk_rq_map_user_io (req , NULL , nvme_to_user_ptr (ubuffer ),
@@ -159,7 +157,7 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
159
157
}
160
158
161
159
if (ret )
162
- goto out ;
160
+ return ret ;
163
161
164
162
bio = req -> bio ;
165
163
if (bdev )
@@ -176,8 +174,6 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
176
174
out_unmap :
177
175
if (bio )
178
176
blk_rq_unmap_user (bio );
179
- out :
180
- blk_mq_free_request (req );
181
177
return ret ;
182
178
}
183
179
@@ -202,7 +198,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
202
198
ret = nvme_map_user_request (req , ubuffer , bufflen , meta_buffer ,
203
199
meta_len , NULL , flags , 0 );
204
200
if (ret )
205
- return ret ;
201
+ goto out_free_req ;
206
202
}
207
203
208
204
bio = req -> bio ;
@@ -218,7 +214,10 @@ static int nvme_submit_user_cmd(struct request_queue *q,
218
214
219
215
if (effects )
220
216
nvme_passthru_end (ctrl , ns , effects , cmd , ret );
217
+ return ret ;
221
218
219
+ out_free_req :
220
+ blk_mq_free_request (req );
222
221
return ret ;
223
222
}
224
223
@@ -521,7 +520,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
521
520
d .data_len , nvme_to_user_ptr (d .metadata ),
522
521
d .metadata_len , ioucmd , vec , issue_flags );
523
522
if (ret )
524
- return ret ;
523
+ goto out_free_req ;
525
524
}
526
525
527
526
/* to free bio on completion, as req->bio will be null at that time */
@@ -531,6 +530,10 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
531
530
req -> end_io = nvme_uring_cmd_end_io ;
532
531
blk_execute_rq_nowait (req , false);
533
532
return - EIOCBQUEUED ;
533
+
534
+ out_free_req :
535
+ blk_mq_free_request (req );
536
+ return ret ;
534
537
}
535
538
536
539
static bool is_ctrl_ioctl (unsigned int cmd )
0 commit comments