From: xypron.glpk@gmx.de Date: Mon, 8 May 2017 18:40:16 +0000 (+0200) Subject: pci: avoid memory leak X-Git-Tag: v2017.07-rc1~318 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c42640c74813f5c9aa9d0d3bdad5ebd565bdfcdc;p=u-boot 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 Reviewed-by: Bin Meng --- diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 40f59c0c4c..504d7e3bb1 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__);