]> www.infradead.org Git - users/jedix/linux-maple.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 Aug 2015 19:21:54 +0000 (12:21 -0700)
commitcb6fd3e6f10bd6c73075dd9a8826e74ed6fffacf
treeaa972275870d0ef2804a9becdae74056af3111eb
parenta77aa615ba7c4d7511993ecf4278bd604da49991
scsi: fix memory leak with scsi-mq

commit 0c958ecc69c277b25f38f72bc6d18ab145e8167c upstream.

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: d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c