linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] pci: endpoint: Fix double free in pci_epf_create()
@ 2018-02-27 10:02 Rolf Evers-Fischer
  2018-02-27 10:02 ` [PATCH v3 1/2] pci: endpoint: Simplify name allocation for epf device Rolf Evers-Fischer
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Rolf Evers-Fischer @ 2018-02-27 10:02 UTC (permalink / raw)
  To: kishon
  Cc: lorenzo.pieralisi, bhelgaas, linux-pci, linux-kernel,
	andy.shevchenko, Rolf Evers-Fischer

This is version 3 of a patchset to avoid double free in function
'pci_epf_create()'.

When I accidentally created a new endpoint device with an empty name,
the kernel warned about "attempted to be registered with empty name!"
and crashed afterwards.

It turned out that the crash was not caused by the 'device_add()'
function itself, but by a double kfree of 'epf->name' and 'epf'.

The first patch just simplifies the code, while the second patch
fixes the problem.

Changes in v3:
- Matched to other pending pci endpoint commits (thanks, Bjorn!)
- Added "Fixes" tag in patch 2 (thanks, Andy!)

Changes in v2:
- Based on feedback from Lorenzo, Andy and Kishon (thanks!)
- Change IDs removed
- First patch completely reworked in order to eliminate the
  need for the second 'kstrdup' allocation and the 'kfree' of
  the first allocation.
  It was tested with name="pci_epf_test.0" and name="pci_epb":
  The 'epf->name' was "pci_epf_test" or "pci_epb" (=unchanged).

Rolf Evers-Fischer (2):
  pci: endpoint: Simplify name allocation for epf device
  pci: endpoint: Fix kernel panic after put_device()

 drivers/pci/endpoint/pci-epf-core.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

-- 
2.16.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-02-28 10:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 10:02 [PATCH v3 0/2] pci: endpoint: Fix double free in pci_epf_create() Rolf Evers-Fischer
2018-02-27 10:02 ` [PATCH v3 1/2] pci: endpoint: Simplify name allocation for epf device Rolf Evers-Fischer
2018-02-27 10:09   ` Kishon Vijay Abraham I
2018-02-27 10:15     ` Rolf Evers-Fischer
2018-02-27 10:43       ` Kishon Vijay Abraham I
2018-02-27 10:02 ` [PATCH v3 2/2] pci: endpoint: Fix kernel panic after put_device() Rolf Evers-Fischer
2018-02-27 10:43   ` Kishon Vijay Abraham I
2018-02-27 17:57   ` Lorenzo Pieralisi
2018-02-28 10:29     ` Rolf Evers-Fischer
2018-02-27 10:20 ` [PATCH v3 0/2] pci: endpoint: Fix double free in pci_epf_create() Lorenzo Pieralisi
2018-02-27 12:11   ` Rolf Evers-Fischer
2018-02-27 14:52   ` Bjorn Helgaas
2018-02-28 10:35     ` Rolf Evers-Fischer
2018-02-27 16:13 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).