Subject: Re: [PATCH] netdevsim: Fix memory leak of nsim_dev->fa_cookie

From: Jakub Kicinski <[email-masked]>
Date: Mon, 14 Nov 2022 18:50:28 -0800

On Sat, 12 Nov 2022 14:28:05 +0800 Wang Yufen wrote:
> nsim_dev_trap_fa_cookie_write()
>   kmalloc() fa_cookie
>   nsim_dev->fa_cookie = fa_cookie
> ..
> nsim_drv_remove()
> 
> nsim_dev->fa_cookie alloced, but the nsim_dev_trap_report_work()
> job has not been done, the flow action cookie has not been assigned
> to the metadata. To fix, add kfree(nsim_dev->fa_cookie) to
> nsim_drv_remove().

I don't see the path thru nsim_dev_trap_report_work() which would free
the fa_cookie.

The fix looks right, but the commit message seems incorrect. Isn't the
leak always there, without any race?