Unverified Commit 81d3c729 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12342 nvmet: fix a possible leak when destroy a ctrl during qp establishment

parents e4a7e972 2236ef18
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -795,6 +795,15 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
	wait_for_completion(&sq->free_done);
	percpu_ref_exit(&sq->ref);

	/*
	 * we must reference the ctrl again after waiting for inflight IO
	 * to complete. Because admin connect may have sneaked in after we
	 * store sq->ctrl locally, but before we killed the percpu_ref. the
	 * admin connect allocates and assigns sq->ctrl, which now needs a
	 * final ref put, as this ctrl is going away.
	 */
	ctrl = sq->ctrl;

	if (ctrl) {
		/*
		 * The teardown flow may take some time, and the host may not