summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>2017-05-08 18:40:16 (GMT)
committerTom Rini <trini@konsulko.com>2017-05-12 12:37:18 (GMT)
commitc42640c74813f5c9aa9d0d3bdad5ebd565bdfcdc (patch)
treeec951c7937cd3094c91dc482113470e2aeabf390 /drivers/pci
parent902f5bcfbcbc8dce964a69e4c9fcf658dfb62998 (diff)
downloadu-boot-c42640c74813f5c9aa9d0d3bdad5ebd565bdfcdc.tar.xz
pci: avoid memory leak
strdup uses malloc to allocate memory for str. If we cannot bind to the generic driver we should release the memory. The problem was indicated by clang scan-build. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-uclass.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 40f59c0..504d7e3 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -660,6 +660,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
ret = device_bind_driver(parent, drv, str, devp);
if (ret) {
debug("%s: Failed to bind generic driver: %d\n", __func__, ret);
+ free(str);
return ret;
}
debug("%s: No match found: bound generic driver instead\n", __func__);