]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
block: Fix memory leak in rw_copy_check_uvector() handling
authorChristian Engelmayer <cengelma@gmx.at>
Sun, 19 Jan 2014 01:08:49 +0000 (02:08 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 22 Jan 2014 04:36:17 +0000 (20:36 -0800)
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>
block/scsi_ioctl.c

index 625e3e471d65f55495bd639b0418e8ad85d53d62..26487972ac549ba899a723201125e5b3c59934ff 100644 (file)
@@ -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;