]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/eeh: Fix possible null deref in eeh_dump_dev_log()
authorSam Bobroff <sbobroff@linux.ibm.com>
Wed, 12 Sep 2018 01:23:20 +0000 (11:23 +1000)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:58:36 +0000 (19:58 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836802
[ Upstream commit f9bc28aedfb5bbd572d2d365f3095c1becd7209b ]

If an error occurs during an unplug operation, it's possible for
eeh_dump_dev_log() to be called when edev->pdn is null, which
currently leads to dereferencing a null pointer.

Handle this by skipping the error log for those devices.

Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/kernel/eeh.c

index cbca0a6676829fe5ac4368365ef48d7deff66e32..e106470531ee9882df34c2e473a2194a90d608fd 100644 (file)
@@ -169,6 +169,11 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
        int n = 0, l = 0;
        char buffer[128];
 
+       if (!pdn) {
+               pr_warn("EEH: Note: No error log for absent device.\n");
+               return 0;
+       }
+
        n += scnprintf(buf+n, len-n, "%04x:%02x:%02x.%01x\n",
                       pdn->phb->global_number, pdn->busno,
                       PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));