Skip to content

Commit

Permalink
staging: slicoss: fix a leak when kzalloc fail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Devendra Naga authored and Greg Kroah-Hartman committed Oct 26, 2012
1 parent db9d1f6 commit 34ec83f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/staging/slicoss/slicoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 34ec83f

Please sign in to comment.