PCI: mvebu: Fix memory leaks and refcount leaks
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 3 Oct 2015 18:13:02 +0000 (19:13 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 9 Oct 2015 16:20:23 +0000 (11:20 -0500)
commit37bfa771cda1734454e4304050cfddbcda5f16ed
treef736c99b0145684331f1a1a8cbea2f1dc861b895
parent49cb1f718360f86075341e35fad57748a5c182f9
PCI: mvebu: Fix memory leaks and refcount leaks

The mvebu PCI port parsing is weak due to:

1) allocations via kasprintf() were not cleaned up when we encounter an
   error or decide to skip the port.
2) kasprintf() wasn't checked for failure.
3) of_get_named_gpio_flags() returns EPROBE_DEFER if the GPIO is not
   present, not devm_gpio_request_one().
4) the of_node was not being put when terminating the loop.

Fix these oversights.

Tested-by: Willy Tarreau <w@1wt.eu> (Iomega iConnect Kirkwood, MiraBox Armada 370)
Tested-by: Andrew Lunn <andrew@lunn.ch> (D-Link DIR664 Kirkwood)
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
drivers/pci/host/pci-mvebu.c