]> git.baikalelectronics.ru Git - kernel.git/commit
nvme-pci: fix memory leak on probe failure
authorKeith Busch <keith.busch@intel.com>
Wed, 11 Jul 2018 22:44:44 +0000 (16:44 -0600)
committerChristoph Hellwig <hch@lst.de>
Thu, 12 Jul 2018 06:23:56 +0000 (08:23 +0200)
commit987898f0b6c149a912fd3b6fcb9510bd5324d262
treed8ae6812233e06ffe1140a44afca7fbe4d5c32ef
parentf07ece0f1d3917dc9b66ec0a0de22877a53115da
nvme-pci: fix memory leak on probe failure

The nvme driver specific structures need to be initialized prior to
enabling the generic controller so we can unwind on failure with out
using the reference counting callbacks so that 'probe' and 'remove'
can be symmetric.

The newly added iod_mempool is the only resource that was being
allocated out of order, and a failure there would leak the generic
controller memory. This patch just moves that allocation above the
controller initialization.

Fixes: aee4f3326a2fd ("nvme-pci: limit max IO size and segments to avoid high order allocations")
Reported-by: Weiping Zhang <zwp10758@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/pci.c