* [PATCH] block: Fix memory leak in rw_copy_check_uvector() handling
@ 2014-01-19 1:08 Christian Engelmayer
2014-01-22 4:36 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Christian Engelmayer @ 2014-01-19 1:08 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
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>
---
block/scsi_ioctl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 625e3e4..2648797 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,
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;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: Fix memory leak in rw_copy_check_uvector() handling
2014-01-19 1:08 [PATCH] block: Fix memory leak in rw_copy_check_uvector() handling Christian Engelmayer
@ 2014-01-22 4:36 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2014-01-22 4:36 UTC (permalink / raw)
To: Christian Engelmayer; +Cc: linux-kernel
On Sun, Jan 19 2014, Christian Engelmayer wrote:
> 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.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-22 4:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-19 1:08 [PATCH] block: Fix memory leak in rw_copy_check_uvector() handling Christian Engelmayer
2014-01-22 4:36 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox