qeth: fix possible memory leak in qeth_l3_add_[vipa|rxip]()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Mon, 24 Sep 2012 04:24:25 +0000 (04:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Sep 2012 19:45:17 +0000 (15:45 -0400)
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>
drivers/s390/net/qeth_l3_main.c

index c5f03fa70fbaea0e774da0891a1ba9338c69f88d..4cd310cb5bdf8f1c070cc1193294928015834a94 100644 (file)
@@ -794,6 +794,7 @@ int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,
                rc = -EEXIST;
        spin_unlock_irqrestore(&card->ip_lock, flags);
        if (rc) {
+               kfree(ipaddr);
                return rc;
        }
        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;
        spin_unlock_irqrestore(&card->ip_lock, flags);
        if (rc) {
+               kfree(ipaddr);
                return rc;
        }
        if (!qeth_l3_add_ip(card, ipaddr))