megaraid_sas: fix memory leak if SGL has zero length entries (Closes: #688198)

svn path=/dists/sid/linux/; revision=19600
This commit is contained in:
Ben Hutchings 2012-12-10 00:14:48 +00:00
parent 3e0d1c3fcb
commit 6ded575e90
3 changed files with 42 additions and 0 deletions

2
debian/changelog vendored
View File

@ -124,6 +124,8 @@ linux (3.2.35-1) UNRELEASED; urgency=low
- hrtimer: Raise softirq if hrtimer irq stalled
- rcu: Disable RCU_FAST_NO_HZ on RT
- net: netfilter: Serialize xt_write_recseq sections on RT
* megaraid_sas: fix memory leak if SGL has zero length entries
(Closes: #688198)
[ Ian Campbell ]
* [xen] add support for microcode updating. (Closes: #693053)

View File

@ -0,0 +1,39 @@
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
Date: Wed, 21 Nov 2012 09:54:48 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Subject: [PATCH] megaraid_sas: fix memory leak if SGL has zero length entries
Content-Transfer-Encoding: 8bit
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
Cc: <stable@vger.kernel.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Adam Radford <aradford@gmail.com>
---
drivers/scsi/megaraid/megaraid_sas_base.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4886,10 +4886,12 @@ megasas_mgmt_fw_ioctl(struct megasas_ins
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);

View File

@ -430,3 +430,4 @@ bugfix/all/kmod-introduce-call_modprobe-helper.patch
bugfix/all/kmod-make-__request_module-killable.patch
bugfix/all/exec-do-not-leave-bprm-interp-on-stack.patch
bugfix/all/exec-use-ELOOP-for-max-recursion-depth.patch
bugfix/all/megaraid_sas-fix-memory-leak-if-SGL-has-zero-length-entries.patch