Re: [PATCH v2] net: macsec: fix potential resource leak in macsec_add_rxsa() and macsec_add_txsa()

From: Paolo Abeni
Date: Tue Jul 12 2022 - 09:16:04 EST


On Mon, 2022-07-11 at 15:28 +0800, Jianglei Nie wrote:
> init_rx_sa() allocates relevant resource for rx_sa->stats and rx_sa->
> key.tfm with alloc_percpu() and macsec_alloc_tfm(). When some error
> occurs after init_rx_sa() is called in macsec_add_rxsa(), the function
> released rx_sa with kfree() without releasing rx_sa->stats and rx_sa->
> key.tfm, which will lead to a resource leak.
>
> We should call macsec_rxsa_put() instead of kfree() to decrease the ref
> count of rx_sa and release the relevant resource if the refcount is 0.
> The same bug exists in macsec_add_txsa() for tx_sa as well. This patch
> fixes the above two bugs.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@xxxxxxx>

uhmmm.... this is getting weird. I already asked you 2 times to please
add a suitable Fixes tag to your commit message, and this patch has
been reposted unmodified...

Please, read every document under Documentation/process/ carefully, and
please really add the required tag next time.

If the above is not clear, please ask questions, but _do not repost_
your patch unmodified,

thanks!

Paolo