summaryrefslogtreecommitdiffstats
path: root/drivers/block/cciss.c
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2007-07-31 00:39:39 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-31 15:39:43 -0700
commitf2912a1223c0917a7b4e054f18086209137891ea (patch)
treebb5598f1c205244277ce352951bc9de1800d0df1 /drivers/block/cciss.c
parentff0cfc66cd99d59e3a8024003171035e4ae192b7 (diff)
downloadtalos-op-linux-f2912a1223c0917a7b4e054f18086209137891ea.tar.gz
talos-op-linux-f2912a1223c0917a7b4e054f18086209137891ea.zip
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. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Acked-by: Mike Miller <mike.miller@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/cciss.c')
-rw-r--r--drivers/block/cciss.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 1be82d544dc3..a11b2bd54bbe 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
}
OpenPOWER on IntegriCloud