PCI/hotplug: ppc: correct a php_slot usage after free
authorSimon Guo <wei.guo.simon@gmail.com>
Wed, 7 Mar 2018 08:46:04 +0000 (16:46 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 13 Mar 2018 04:50:32 +0000 (15:50 +1100)
In pnv_php_unregister_one(), pnv_php_put_slot() might kfree
php_slot structure. But there is pci_hp_deregister() after
that with php_slot reference.

This patch moves pnv_php_put_slot() to the end of function.

Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/pci/hotplug/pnv_php.c

index 23da3046f160d6527805bc22484fc004fe0a8703..d44100687dfea9411b609a3526775797b1fdb3a6 100644 (file)
@@ -919,8 +919,8 @@ static void pnv_php_unregister_one(struct device_node *dn)
                return;
 
        php_slot->state = PNV_PHP_STATE_OFFLINE;
-       pnv_php_put_slot(php_slot);
        pci_hp_deregister(&php_slot->slot);
+       pnv_php_put_slot(php_slot);
 }
 
 static void pnv_php_unregister(struct device_node *dn)