aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/slicoss
diff options
context:
space:
mode:
authorDevendra Naga <devendra.aaru@gmail.com>2012-10-25 02:11:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-26 09:36:06 -0700
commit34ec83f4c1dc0d6bf4b056f89841706907a06255 (patch)
tree0f5b084b6e11901ae8d2b49cebb1002dfd731e67 /drivers/staging/slicoss
parentdb9d1f6dd2601aee860304ffc1023a7d5709f314 (diff)
staging: slicoss: fix a leak when kzalloc fail
slic_card_locate does a kzalloc of physcard, and if it fails, in my previous patch i returned -ENOMEM, but left the driver leak the memory if card_hostid == SLIC_HOSTID_DEFAULT, fix this memory leak if the above condition is true Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/slicoss')
-rw-r--r--drivers/staging/slicoss/slicoss.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index f08f4593b18..ee0f0e4e41a 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -3657,8 +3657,11 @@ static u32 slic_card_locate(struct adapter *adapter)
if (!physcard) {
/* no structure allocated for this physical card yet */
physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
- if (!physcard)
+ if (!physcard) {
+ if (card_hostid == SLIC_HOSTID_DEFAULT)
+ kfree(card);
return -ENOMEM;
+ }
physcard->next = slic_global.phys_card;
slic_global.phys_card = physcard;