From 087ef34b9ccef5beb671a65a2069c375574fb38d Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 24 Sep 2024 16:14:54 +0200 Subject: [PATCH] aco: fix descriptor leaking when printing assembly with CLRX This can explode the maximum number of descriptors. Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/compiler/aco_print_asm.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_print_asm.cpp b/src/amd/compiler/aco_print_asm.cpp index d21acd47623..691be619415 100644 --- a/src/amd/compiler/aco_print_asm.cpp +++ b/src/amd/compiler/aco_print_asm.cpp @@ -161,6 +161,7 @@ print_asm_clrx(Program* program, std::vector& binary, unsigned exec_si #else char path[] = "/tmp/fileXXXXXX"; char line[2048], command[128]; + bool ret = false; FILE* p; int fd; @@ -172,8 +173,10 @@ print_asm_clrx(Program* program, std::vector& binary, unsigned exec_si return true; for (unsigned i = 0; i < exec_size; i++) { - if (write(fd, &binary[i], 4) == -1) + if (write(fd, &binary[i], 4) == -1) { + ret = true; goto fail; + } } sprintf(command, "clrxdisasm --gpuType=%s -r %s", gpu_type, path); @@ -183,6 +186,7 @@ print_asm_clrx(Program* program, std::vector& binary, unsigned exec_si if (!fgets(line, sizeof(line), p)) { fprintf(output, "clrxdisasm not found\n"); pclose(p); + ret = true; goto fail; } @@ -239,12 +243,10 @@ print_asm_clrx(Program* program, std::vector& binary, unsigned exec_si print_constant_data(output, program); } - return false; - fail: close(fd); unlink(path); - return true; + return ret; #endif }