From ae674792c32bc54832e52706ec669d59cbea7ab6 Mon Sep 17 00:00:00 2001 From: Tony Battersby Date: Thu, 23 Oct 2014 15:10:21 -0400 Subject: lib/scatterlist: fix memory leak with scsi-mq Fix a memory leak with scsi-mq triggered by commands with large data transfer length. Fixes: c53c6d6a68b1 ("scatterlist: allow chaining to preallocated chunks") Cc: # 3.17.x Signed-off-by: Tony Battersby Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- lib/scatterlist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 9cdf62f..c9f2e8c 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -203,10 +203,10 @@ void __sg_free_table(struct sg_table *table, unsigned int max_ents, } table->orig_nents -= sg_size; - if (!skip_first_chunk) { - free_fn(sgl, alloc_size); + if (skip_first_chunk) skip_first_chunk = false; - } + else + free_fn(sgl, alloc_size); sgl = next; } -- cgit v1.1