]> git.sur5r.net Git - u-boot/commitdiff
pci: avoid memory leak
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Mon, 8 May 2017 18:40:16 +0000 (20:40 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 12 May 2017 12:37:18 +0000 (08:37 -0400)
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>
drivers/pci/pci-uclass.c

index 40f59c0c4c439a3a97a982590b64fcfc9c57e52d..504d7e3bb134d1422e901cda320c4a1a3b2df093 100644 (file)
@@ -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__);