Todd Fleisher <t...@fleetstreetops.com> writes: > FYI - I'm seeing this same issue in Ubuntu 12.04: Linux deb015.pod02 > 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 > x86_64 x86_64 GNU/Linux
Shit! I have a bad feeling I might be responsible here... Looks like the "fix" I submitted a while ago results in leaking dma_allocated memory instead of BUGing out. Maybe slightly better in a short term, but slightly more difficult to notice. Does it take a while before this error starts appearing? Do you run some smartctl commands periodically? I'd appreciate it if the good Debian kernel team could tak a look at this before it goes upstream, but I believe something like the attached patch might fix the bug. This patch is based on v3.2.34, but I'll rebase it on current mainline and submit it upstream with Cc stable if any of you confirms that this look sane Bjørn
>From 4c41818461c2604f859d2fecda2657827071f0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bj...@mork.no> Date: Tue, 20 Nov 2012 18:17:48 +0100 Subject: [PATCH] megaraid_sas: fix memory leak if SGL has 0 length entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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. Signed-off-by: Bjørn Mork <bj...@mork.no> --- drivers/scsi/megaraid/megaraid_sas_base.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 7c471eb..f013432 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4886,8 +4886,9 @@ 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, + 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); } -- 1.7.10.4