From 3659c93d70354f8548cd7670b849e0ee21445863 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 3 Oct 2014 12:27:30 +0000 Subject: [PATCH] scst_mem: Fix a memory leak triggered by the scst_user driver (merge r5829 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x@5830 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_mem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index ea099a727..7bc6b4418 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1021,7 +1021,13 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, goto out_fail_free; } - TRACE_MEM("Brand new obj %p", obj); + if (likely(!obj->recycling_list_entry.next)) { + TRACE_MEM("Brand new obj %p", obj); + } else if (unlikely(obj->sg_entries != obj->sg_entries_data)) { + TRACE_MEM("Cached obj %p with sg_count == 0", obj); + kfree(obj->sg_entries); + obj->sg_entries = NULL; + } if (pages_to_alloc <= sgv_max_local_pages) { obj->sg_entries = obj->sg_entries_data;