aboutsummaryrefslogtreecommitdiffstats
path: root/block/scsi_ioctl.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-08-21 21:38:27 -0400
committerJens Axboe <axboe@fb.com>2014-08-21 21:42:01 -0400
commit2cada584b20007470931080c49310d85908449b0 (patch)
tree1e2a191bc3e9017b6b40a961a6efdcb0d804fc54 /block/scsi_ioctl.c
parentaeac31819475ad0980cb3a13d5599f5a1127e83d (diff)
block: cleanup error handling in sg_io
Make sure we always clean up through the out label and just have a single place to put the request. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r--block/scsi_ioctl.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 51bf5155ee75..ba8706f6cded 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -279,7 +279,6 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
279 r = blk_rq_unmap_user(bio); 279 r = blk_rq_unmap_user(bio);
280 if (!ret) 280 if (!ret)
281 ret = r; 281 ret = r;
282 blk_put_request(rq);
283 282
284 return ret; 283 return ret;
285} 284}
@@ -322,10 +321,9 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
322 return -ENOMEM; 321 return -ENOMEM;
323 blk_rq_set_block_pc(rq); 322 blk_rq_set_block_pc(rq);
324 323
325 if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { 324 ret = -EFAULT;
326 blk_put_request(rq); 325 if (blk_fill_sghdr_rq(q, rq, hdr, mode))
327 return -EFAULT; 326 goto out;
328 }
329 327
330 if (hdr->iovec_count) { 328 if (hdr->iovec_count) {
331 size_t iov_data_len; 329 size_t iov_data_len;
@@ -376,7 +374,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
376 374
377 hdr->duration = jiffies_to_msecs(jiffies - start_time); 375 hdr->duration = jiffies_to_msecs(jiffies - start_time);
378 376
379 return blk_complete_sghdr_rq(rq, hdr, bio); 377 ret = blk_complete_sghdr_rq(rq, hdr, bio);
380out: 378out:
381 blk_put_request(rq); 379 blk_put_request(rq);
382 return ret; 380 return ret;