浏览代码

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>
xypron.glpk@gmx.de 8 年之前
父节点
当前提交
c42640c748
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      drivers/pci/pci-uclass.c

+ 1 - 0
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__);