From 739c9025dbe84f54c47f5cc960e4d90dc830e2fe Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 10 Feb 2015 08:11:35 +0000 Subject: [PATCH] scst_scsi_exec_async(): Fix a recently introduced memory leak (merge r6016 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@6032 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 5bd950d06..8b9b4e9fb 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6797,7 +6797,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, if (!test_bit(QUEUE_FLAG_BIDI, &q->queue_flags)) { res = -EOPNOTSUPP; - goto out; + goto out_free_sioc; } rq = blk_map_kern_sg(q, cmd->out_sg, cmd->out_sg_cnt, gfp, @@ -6805,7 +6805,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, if (IS_ERR(rq)) { res = PTR_ERR(rq); TRACE_DBG("blk_map_kern_sg() failed: %d", res); - goto out; + goto out_free_sioc; } next_rq = blk_map_kern_sg(q, cmd->sg, cmd->sg_cnt, gfp, false); @@ -6820,7 +6820,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, if (IS_ERR(rq)) { res = PTR_ERR(rq); TRACE_DBG("blk_map_kern_sg() failed: %d", res); - goto out; + goto out_free_sioc; } } @@ -6861,6 +6861,9 @@ out_free_unmap: rq->bio = NULL; blk_put_request(rq); + +out_free_sioc: + kmem_cache_free(scsi_io_context_cache, sioc); goto out; } EXPORT_SYMBOL(scst_scsi_exec_async);