提交 c30efbae 编写于 作者: D Dave Jones

[AGPGART] Prevent (unlikely) memory leak in amd_create_gatt_pages()

If we fail an alloc, unwind the previous allocs that succeeded.
Spotted-by: NAlan Grimes <agrimes@speakeasy.net>
Signed-off-by: NDave Jones <davej@redhat.com>
上级 4b95320f
......@@ -101,6 +101,11 @@ static int amd_create_gatt_pages(int nr_tables)
for (i = 0; i < nr_tables; i++) {
entry = kzalloc(sizeof(struct amd_page_map), GFP_KERNEL);
if (entry == NULL) {
while (i > 0) {
kfree(tables[i-1]);
i--;
}
kfree(tables);
retval = -ENOMEM;
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册