From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA09A1170E for ; Mon, 11 Sep 2023 14:23:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BCCDC433C8; Mon, 11 Sep 2023 14:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694442209; bh=gAWiwxWiTY3mPjT8Id58dtsnOWPln5rbSnyPHnIDHco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FPdHdJeFO+77qoJUJISjP6YVSmyePK5lzXRoWwXuVzu6qtuo38codQyS+2Z+4Ok/k KYHYSW3bmLiQlNGWE/JIk9G9qvCLRClHAN5MVTjF7RhPxj1hGoFSHP2gaZzlfhjUu0 1EgU3qhyhdiBPlW7s9uSom7HOJ2dE/C6NCjzABFk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dexuan Cui , Lorenzo Pieralisi , sathyanarayanan.kuppuswamy@linux.intel.com, Michael Kelley Subject: [PATCH 6.5 685/739] PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation Date: Mon, 11 Sep 2023 15:48:04 +0200 Message-ID: <20230911134710.232144252@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.921299741@linuxfoundation.org> References: <20230911134650.921299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dexuan Cui commit 04bbe863241a9be7d57fb4cf217ee4a72f480e70 upstream. When a Linux VM with an assigned PCI device runs on Hyper-V, if the PCI device driver is not loaded yet (i.e. MSI-X/MSI is not enabled on the device yet), doing a VM hibernation triggers a panic in hv_pci_restore_msi_msg() -> msi_lock_descs(&pdev->dev), because pdev->dev.msi.data is still NULL. Avoid the panic by checking if MSI-X/MSI is enabled. Link: https://lore.kernel.org/r/20230816175939.21566-1-decui@microsoft.com Fixes: dc2b453290c4 ("PCI: hv: Rework MSI handling") Signed-off-by: Dexuan Cui Signed-off-by: Lorenzo Pieralisi Reviewed-by: sathyanarayanan.kuppuswamy@linux.intel.com Reviewed-by: Michael Kelley Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-hyperv.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -3983,6 +3983,9 @@ static int hv_pci_restore_msi_msg(struct struct msi_desc *entry; int ret = 0; + if (!pdev->msi_enabled && !pdev->msix_enabled) + return 0; + msi_lock_descs(&pdev->dev); msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) { irq_data = irq_get_irq_data(entry->irq);