[PATCH 3.17 250/319] lib/scatterlist: fix memory leak with scsi-mq

From: Greg Kroah-Hartman
Date: Tue Nov 11 2014 - 20:34:33 EST


3.17-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tony Battersby <tonyb@xxxxxxxxxxxxxxx>

commit c21e59d8dc04b2107bdb4ff0f412a9b7ae3349f3 upstream.

Fix a memory leak with scsi-mq triggered by commands with large data
transfer length.

Fixes: c53c6d6a68b1 ("scatterlist: allow chaining to preallocated chunks")
Signed-off-by: Tony Battersby <tonyb@xxxxxxxxxxxxxxx>
Reviewed-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Signed-off-by: Jens Axboe <axboe@xxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
lib/scatterlist.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -203,10 +203,10 @@ void __sg_free_table(struct sg_table *ta
}

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;
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/