提交 34ec83f4 编写于 作者: D Devendra Naga 提交者: Greg Kroah-Hartman

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: NDevendra Naga <devendra.aaru@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 db9d1f6d
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册