diff options
author | Bjørn Mork <bjorn@mork.no> | 2012-11-21 09:54:48 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-28 16:26:09 -0700 |
commit | 5c88c30cc3cff0bbd1ee722460a4e96bf29b62dc (patch) | |
tree | 8ca9b0fdbc3da791bb08eb072849955fac4a0d71 /drivers/scsi | |
parent | 1150363e16fb0b830131d70b2158664483fb0147 (diff) | |
download | lwn-5c88c30cc3cff0bbd1ee722460a4e96bf29b62dc.tar.gz lwn-5c88c30cc3cff0bbd1ee722460a4e96bf29b62dc.zip |
SCSI: megaraid_sas: fix memory leak if SGL has zero length entries
commit 7a6a731bd00ca90d0e250867c3b9c05b5ff0fa49 upstream.
commit 98cb7e44 ([SCSI] megaraid_sas: Sanity check user
supplied length before passing it to dma_alloc_coherent())
introduced a memory leak. Memory allocated for entries
following zero length SGL entries will not be freed.
Reference: http://bugs.debian.org/688198
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Adam Radford <aradford@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_base.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6308a8ddf6ff..073d5ad30381 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4817,10 +4817,12 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, sense, sense_handle); } - for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) { - dma_free_coherent(&instance->pdev->dev, - kern_sge32[i].length, - kbuff_arr[i], kern_sge32[i].phys_addr); + for (i = 0; i < ioc->sge_count; i++) { + if (kbuff_arr[i]) + dma_free_coherent(&instance->pdev->dev, + kern_sge32[i].length, + kbuff_arr[i], + kern_sge32[i].phys_addr); } megasas_return_cmd(instance, cmd); |