Re: [PATCH v3] IB/mlx4: Fix refcount leak in add_port() error path

From: Guangshuo Li

Date: Tue Apr 28 2026 - 12:50:01 EST


Hi Jason,

Thanks for reviewing.

On Wed, 29 Apr 2026 at 00:06, Jason Gunthorpe <jgg@xxxxxxxx> wrote:
>
> Do not put double returns in goto-unwinds..
>
> This should be fixed to open code the kobject_init() immediately after
> the memory allocation so we never switch between kfree and put, and fix
> all the release functions to tolerate half initialized objects.
>
> Then you can remove the mess of kfrees which are all duplicated in the
> release function.
>
> Jason

I will respin this so that all failures after kobject_init_and_add()
use a single kobject_put() based unwind path. The duplicated kfree()
handling in add_port() will be removed, and mlx4_port_release() will
tolerate partially initialized mlx4_port objects.