]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: fix memory leak with scsi-mq
authorTony Battersby <tonyb@cybernetics.com>
Thu, 16 Jul 2015 15:40:41 +0000 (11:40 -0400)
committerJames Bottomley <JBottomley@Odin.com>
Thu, 30 Jul 2015 17:40:33 +0000 (10:40 -0700)
commit227f3d18ffecc01f27b819c6b5f73999a5b3a804
treebc2bad55954762cbafac0651b2250675762e890b
parent4737d2156dc5ef8665c0a6beea0aa9a90ba8c530
scsi: fix memory leak with scsi-mq

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

__sg_alloc_table() sets both table->nents and table->orig_nents to the
same value.  When the scatterlist is DMA-mapped, table->nents is
overwritten with the (possibly smaller) size of the DMA-mapped
scatterlist, while table->orig_nents retains the original size of the
allocated scatterlist.  scsi_free_sgtable() should therefore check
orig_nents instead of nents, and all code that initializes sdb->table
without calling __sg_alloc_table() should set both nents and orig_nents.

Fixes: baba6d160fda ("scsi: add support for a blk-mq based I/O path.")
Cc: <stable@vger.kernel.org> # 3.17+
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c