diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2008-02-07 21:03:11 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-25 15:59:17 -0800 |
commit | bc0fb02f5fd30a518b659320b89ee58ea78fb979 (patch) | |
tree | 5f619c13e28ead9db09bae74dddefde278e5c8a6 | |
parent | e2f18d53125bf0753169de321af25b0df1b758c5 (diff) | |
download | lwn-bc0fb02f5fd30a518b659320b89ee58ea78fb979.tar.gz lwn-bc0fb02f5fd30a518b659320b89ee58ea78fb979.zip |
cciss: fix memory leak
mainline: f2912a1223c0917a7b4e054f18086209137891ea
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>
Cc: Oliver Pinter <oliver.pntr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/block/cciss.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 5acc6c44aead..132f76bc86c9 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -3225,12 +3225,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; } |