Re: [PATCH v2 RESEND] PCI: fix reference leak in pci_register_host_bridge()

Krzysztof Wilczyński
2025-03-03T07:42:52Z

Hello,

> Once device_register() failed, we should call put_device() to
> decrement reference count for cleanup. Or it could cause memory leak.
>
> device_register() includes device_add(). As comment of device_add()
> says, 'if device_add() succeeds, you should call device_del() when you
> want to get rid of it. If device_add() has not succeeded, use only
> put_device() to drop the reference count'.
>
> Found by code review.

Bjorn took this already, see:

https://lore.kernel.org/linux-pci/20250227220124.GA19560@bhelgaas

That said, you need to ease on the resends a bit. We track your patches
and we will get to these eventually. Please relax a bit, and perhaps focus
your energy here on offering code reviews for other changes, which is
always a great thing to do and helps us a lot. :)

Thank you!

Krzysztof