Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: <stable@vger.kernel.org> # 3.17.x
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Tony Battersby and committed by
Jens Axboe
c21e59d8 d32f6b57

+3 -3
+3 -3
lib/scatterlist.c
··· 203 203 } 204 204 205 205 table->orig_nents -= sg_size; 206 - if (!skip_first_chunk) { 207 - free_fn(sgl, alloc_size); 206 + if (skip_first_chunk) 208 207 skip_first_chunk = false; 209 - } 208 + else 209 + free_fn(sgl, alloc_size); 210 210 sgl = next; 211 211 } 212 212