PCI: hv: Fix the PCI HyperV probe failure path to release resource properly
authorWei Hu <weh@microsoft.com>
Thu, 7 May 2020 05:02:11 +0000 (13:02 +0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 11 May 2020 11:04:35 +0000 (12:04 +0100)
commit83cc3508ffaa6e2cd364d29418d35fab6f069b51
treed67c45ae6b96a1fc9b2837c888d5cb30d1622465
parent8f3d9f354286745c751374f5f1fcafee6b3f3136
PCI: hv: Fix the PCI HyperV probe failure path to release resource properly

In some error cases in hv_pci_probe(), allocated resources are not freed.

Fix this by adding a field to keep track of the high water mark for slots
that have resources allocated to them.  In case of an error, this high
water mark is used to know which slots have resources that must be released.
Since slots are numbered starting with zero, a value of -1 indicates no
slots have been allocated resources.  There may be unused slots in the range
between slot 0 and the high water mark slot, but these slots are already
ignored by the existing code in the allocate and release loops with the call
to get_pcichild_wslot().

Link: https://lore.kernel.org/r/20200507050211.10923-1-weh@microsoft.com
Signed-off-by: Wei Hu <weh@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
drivers/pci/controller/pci-hyperv.c