macsec: fix memory leaks around rx_handler (un)registration

We leak a struct macsec_rxh_data when we unregister the rx_handler in
macsec_dellink.
We also leak a struct macsec_rxh_data in register_macsec_dev if we fail
to register the rx_handler.

Fixes: c09440f7dc ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sabrina Dubroca 2016-04-22 11:28:06 +02:00 committed by David S. Miller
parent 96cfc5052c
commit 960d5848db

View File

@ -2931,8 +2931,10 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
unregister_netdevice_queue(dev, head); unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys); list_del_rcu(&macsec->secys);
if (list_empty(&rxd->secys)) if (list_empty(&rxd->secys)) {
netdev_rx_handler_unregister(real_dev); netdev_rx_handler_unregister(real_dev);
kfree(rxd);
}
macsec_del_dev(macsec); macsec_del_dev(macsec);
} }
@ -2954,9 +2956,11 @@ static int register_macsec_dev(struct net_device *real_dev,
err = netdev_rx_handler_register(real_dev, macsec_handle_frame, err = netdev_rx_handler_register(real_dev, macsec_handle_frame,
rxd); rxd);
if (err < 0) if (err < 0) {
kfree(rxd);
return err; return err;
} }
}
list_add_tail_rcu(&macsec->secys, &rxd->secys); list_add_tail_rcu(&macsec->secys, &rxd->secys);
return 0; return 0;