Skip to contentSkip to conversation

{05/17} - cciss-fix_memory_leak - series for stable kernel #2

2.6.22.y Oliver Pinter (Pintér Olivér) 1 participant 2 messages Feb 2, 2008 – Feb 6, 2008 Block layer

lore
Share & tools
lore
author Acked-by Mike Miller
#1 lore raw
Quoted 1 line

From f2912a1223c0917a7b4e054f18086209137891ea Mon Sep 17 00:00:00 2001

From: Jesper Juhl <[email protected]>
Date: Tue, 31 Jul 2007 00:39:39 -0700
Subject: [PATCH] cciss: fix memory leak

There's a memory leak in the cciss driver.

in alloc_cciss_hba() we may leak sizeof(ctlr_info_t) bytes if a call to alloc_disk(1 << NWD_SHIFT) fails.
This patch should fix the issue.

Spotted by the Coverity checker.

drivers/block/cciss.c +4 -1
index 1be82d5..a11b2bd 100644
@@ -3227,12 +3227,15 @@ static int alloc_cciss_hba(void)
 	for (i = 0; i < MAX_CTLR; i++) {
 		if (!hba[i]) {
 			ctlr_info_t *p;
+
 			p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
 			if (!p)
 				goto Enomem;
 			p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
-			if (!p->gendisk[0])
+			if (!p->gendisk[0]) {
+				kfree(p);
 				goto Enomem;
+			}
 			hba[i] = p;
 			return i;
 		}
Quoted 6 lines · Oliver Pinter (Pintér Olivér)

mainline: f2912a1223c0917a7b4e054f18086209137891ea

--
Thanks,
Oliver

Signature · 2 lines
Thanks,
Oliver