Skip to content

Commit

Permalink
block: Fix memory leak in rw_copy_check_uvector() handling
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christian Engelmayer authored and axboe committed Jan 22, 2014
1 parent 5837c80 commit 17a05cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,

if (hdr->iovec_count) {
size_t iov_data_len;
struct iovec *iov;
struct iovec *iov = NULL;

ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count,
0, NULL, &iov);
if (ret < 0)
if (ret < 0) {
kfree(iov);
goto out;
}

iov_data_len = ret;
ret = 0;
Expand Down

0 comments on commit 17a05cc

Please sign in to comment.