[PATCH] nvmet: fix refcount leak in nvmet_sq_create()
Keith Busch
kbusch at kernel.org
Tue Jun 9 09:44:27 PDT 2026
On Tue, Jun 09, 2026 at 09:55:05AM +0000, Wentao Liang wrote:
> In nvmet_sq_create(), a reference on the ctrl is taken
> via kref_get_unless_zero() before calling nvmet_check_sqid().
> If nvmet_check_sqid() fails, the function returns the error
> directly without releasing the reference, leading to a leak.
>
> Fix this by jumping to the "ctrl_put" label, which already
> performs the necessary nvmet_ctrl_put(ctrl). This ensures the
> reference is properly released on this error path.
Thanks, applied to nvme-7.2.
More information about the Linux-nvme
mailing list