qeth: fix possible memory leak in qeth_l3_add_[vipa|rxip]()

ipaddr has been allocated in function qeth_l3_add_vipa() but
does not free before leaving from the error handling cases. The
same problem also exists in function qeth_l3_add_rxip().

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Wei Yongjun 2012-09-24 04:24:25 +00:00 committed by David S. Miller
parent 3c78747587
commit f68bd07c41
1 changed files with 2 additions and 0 deletions

View File

@ -794,6 +794,7 @@ int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
rc = -EEXIST; rc = -EEXIST;
spin_unlock_irqrestore(&card->ip_lock, flags); spin_unlock_irqrestore(&card->ip_lock, flags);
if (rc) { if (rc) {
kfree(ipaddr);
return rc; return rc;
} }
if (!qeth_l3_add_ip(card, ipaddr)) if (!qeth_l3_add_ip(card, ipaddr))
@ -858,6 +859,7 @@ int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto,
rc = -EEXIST; rc = -EEXIST;
spin_unlock_irqrestore(&card->ip_lock, flags); spin_unlock_irqrestore(&card->ip_lock, flags);
if (rc) { if (rc) {
kfree(ipaddr);
return rc; return rc;
} }
if (!qeth_l3_add_ip(card, ipaddr)) if (!qeth_l3_add_ip(card, ipaddr))