Blob Blame History Raw
From 9eef6a5c3b0bf90eb292d462ea267bcb6ad1c334 Mon Sep 17 00:00:00 2001
From: Rolf Evers-Fischer <rolf.evers.fischer@aptiv.com>
Date: Wed, 28 Feb 2018 18:32:19 +0100
Subject: [PATCH] PCI: endpoint: Fix kernel panic after put_device()
Git-commit: 9eef6a5c3b0bf90eb292d462ea267bcb6ad1c334
Patch-mainline: v4.17-rc1
References: bsc#1051510

'put_device()' calls the relase function 'pci_epf_dev_release()',
which already frees 'epf->name' and 'epf'.

Therefore we must not free them again after 'put_device()'.

Fixes: 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions")

Signed-off-by: Rolf Evers-Fischer <rolf.evers.fischer@aptiv.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/pci/endpoint/pci-epf-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -254,7 +254,7 @@ struct pci_epf *pci_epf_create(const cha
 
 put_dev:
 	put_device(dev);
-	kfree(epf->name);
+	return ERR_PTR(ret);
 
 free_func_name:
 	kfree(func_name);