diff options
author | Christian Engelmayer <cengelma@gmx.at> | 2014-01-18 20:08:49 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2014-01-21 23:36:17 -0500 |
commit | 17a05cca99d952f5b4766fa48a2703548966636a (patch) | |
tree | 3ecdbd133cbeef9f4bc3fb0a8f1eea4f8e1defa5 /block | |
parent | 5837c80e870bc3b12ac6a98cdc9ce7a9522a8fb6 (diff) |
block: Fix memory leak in rw_copy_check_uvector() handling
Fix a memory leak in the error handling path of function sg_io()
that is used during the processing of scsi ioctl. Memory already
allocated by rw_copy_check_uvector() needs to be freed correctly.
Detected by Coverity: CID 1128953.
Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/scsi_ioctl.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 625e3e471d65..26487972ac54 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -323,12 +323,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, | |||
323 | 323 | ||
324 | if (hdr->iovec_count) { | 324 | if (hdr->iovec_count) { |
325 | size_t iov_data_len; | 325 | size_t iov_data_len; |
326 | struct iovec *iov; | 326 | struct iovec *iov = NULL; |
327 | 327 | ||
328 | ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count, | 328 | ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count, |
329 | 0, NULL, &iov); | 329 | 0, NULL, &iov); |
330 | if (ret < 0) | 330 | if (ret < 0) { |
331 | kfree(iov); | ||
331 | goto out; | 332 | goto out; |
333 | } | ||
332 | 334 | ||
333 | iov_data_len = ret; | 335 | iov_data_len = ret; |
334 | ret = 0; | 336 | ret = 0; |