]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
habanalabs: Add check for pci_enable_device
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 24 Feb 2022 06:58:05 +0000 (14:58 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:58:06 +0000 (11:58 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 9c27896ac1bb83ea5c461ce6f7089d02102a2b21 ]

As the potential failure of the pci_enable_device(),
it should be better to check the return value and return
error if fails.

Fixes: 70b2f993ea4a ("habanalabs: create common folder")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 8a842f88d0e2eb9988e1a35c2d52cb9d26e99d14)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/misc/habanalabs/common/debugfs.c

index 985f1f3dbd20f4fe9062995b19a8e338260243b0..0b46fd22c411bb5b500cb92f414fd125ff208487 100644 (file)
@@ -856,6 +856,8 @@ static ssize_t hl_set_power_state(struct file *f, const char __user *buf,
                pci_set_power_state(hdev->pdev, PCI_D0);
                pci_restore_state(hdev->pdev);
                rc = pci_enable_device(hdev->pdev);
+               if (rc < 0)
+                       return rc;
        } else if (value == 2) {
                pci_save_state(hdev->pdev);
                pci_disable_device(hdev->pdev);