Skip to content

Commit 36b232c

Browse files
qsndavem330
authored andcommitted
macsec: RXSAs don't need to hold a reference on RXSCs
Following the previous patch, RXSCs are held and properly refcounted in the RX path (instead of being implicitly held by their SA), so the SA doesn't need to hold a reference on its parent RXSC. This also avoids panics on module unload caused by the double layer of RCU callbacks (call_rcu frees the RXSA, which puts the final reference on the RXSC and allows to free it in its own call_rcu) that commit b196c22 ("macsec: add rcu_barrier() on module exit") didn't protect against. There were also some refcounting bugs in macsec_add_rxsa where I didn't put the reference on the RXSC on the error paths, which would lead to memory leaks. Fixes: c09440f ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c78ebe1 commit 36b232c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/macsec.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ static void free_rxsa(struct rcu_head *head)
344344

345345
crypto_free_aead(sa->key.tfm);
346346
free_percpu(sa->stats);
347-
macsec_rxsc_put(sa->sc);
348347
kfree(sa);
349348
}
350349

@@ -1653,7 +1652,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
16531652

16541653
rtnl_lock();
16551654
rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy);
1656-
if (IS_ERR(rx_sc) || !macsec_rxsc_get(rx_sc)) {
1655+
if (IS_ERR(rx_sc)) {
16571656
rtnl_unlock();
16581657
return PTR_ERR(rx_sc);
16591658
}

0 commit comments

Comments
 (0)