From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D27C48BE6 for ; Wed, 16 Jun 2021 15:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBA0E60FEE for ; Wed, 16 Jun 2021 15:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235233AbhFPPpQ (ORCPT ); Wed, 16 Jun 2021 11:45:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:51514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235511AbhFPPmH (ORCPT ); Wed, 16 Jun 2021 11:42:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6A0B613CB; Wed, 16 Jun 2021 15:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623857892; bh=45JLVJqfviyJdxA8LcjD9n3/BRyIxOebcdNmA3Perj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sqHGUhHAqp/fYjVYZ8UCJhMDSIhEqG4GIJxxCVhUNqkLkE4GYvHpQEy/YVQhjLt3H 3Lqx1HTUXlk0DHAU84J9lcCqAQatomKto35KYBokUNZFzaJOICfqavc5/0/0uVH6f+ 4i1vwDwjf4TAHcBu6TM2dPKekbw8ZOFowaAO70ok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.12 35/48] nvme-loop: reset queue count to 1 in nvme_loop_destroy_io_queues() Date: Wed, 16 Jun 2021 17:33:45 +0200 Message-Id: <20210616152837.757318393@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210616152836.655643420@linuxfoundation.org> References: <20210616152836.655643420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hannes Reinecke [ Upstream commit a6c144f3d2e230f2b3ac5ed8c51e0f0391556197 ] The queue count is increased in nvme_loop_init_io_queues(), so we need to reset it to 1 at the end of nvme_loop_destroy_io_queues(). Otherwise the function is not re-entrant safe, and crash will happen during concurrent reset and remove calls. Signed-off-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 14913a4588ec..4b2a6330feb5 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -297,6 +297,7 @@ static void nvme_loop_destroy_io_queues(struct nvme_loop_ctrl *ctrl) clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); nvmet_sq_destroy(&ctrl->queues[i].nvme_sq); } + ctrl->ctrl.queue_count = 1; } static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl) -- 2.30.2