On Mon, Dec 01, 2025 at 10:06:24PM +0000, Andre Carvalho wrote:
> On Mon, Dec 01, 2025 at 03:35:04AM -0800, Breno Leitao wrote:
> > might hit a similar problem to the one fixed by e5235eb6cfe0 ("net:
> > netpoll: initialize work queue before error checks")
> >
> > The code path would be:
> > * alloc_param_target()
> > * alloc_and_init()
> > * kzalloc() fails and return NULL.
> > * resume_wq() is still not initialized
> > fail:
> > * free_param_target()
> > * cancel_work_sync(&nt->resume_wq); and resume_wq is not
> > initialized
>
> Checking this a bit now and I'm not sure if we have the same problem. On
> alloc_param_target() the cleanup is simply kfree(nt).
>
> free_param_target() is only called as part of netconsole module setup/cleanup
> but
> only for targets that were succesfully added to the target list (so are
> guaranteed
> to have resume_wq initialised) before we hit the error.
>
> Let me know if I'm missing something!
You are not, fail: code only iterates over the targets in the list. If
kzalloc() fails above, it will not be included in the list, thus,
free_param_target() will not be called.