Commit 0c0cf3d
net: macsec: fix double free of percpu stats
Inside macsec_add_dev() we free percpu macsec->secy.tx_sc.stats and
macsec->stats on some of the memory allocation failure paths. However, the
net_device is already registered to that moment: in macsec_newlink(), just
before calling macsec_add_dev(). This means that during unregister process
its priv_destructor - macsec_free_netdev() - will be called and will free
the stats again.
Remove freeing percpu stats inside macsec_add_dev() because
macsec_free_netdev() will correctly free the already allocated ones. The
pointers to unallocated stats stay NULL, and free_percpu() treats that
correctly.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Fixes: 0a28bfd ("net/macsec: Add MACsec skb_metadata_dst Tx Data path support")
Fixes: c09440f ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent 9eed321 commit 0c0cf3d
1 file changed
Lines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3997 | 3997 | | |
3998 | 3998 | | |
3999 | 3999 | | |
4000 | | - | |
4001 | | - | |
| 4000 | + | |
4002 | 4001 | | |
4003 | | - | |
4004 | 4002 | | |
4005 | 4003 | | |
4006 | | - | |
4007 | | - | |
4008 | | - | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
4009 | 4008 | | |
4010 | | - | |
4011 | 4009 | | |
4012 | 4010 | | |
4013 | 4011 | | |
| |||
0 commit comments