From 046710ce957e8270bf72cff6c358db04c87c3eca Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 11 Aug 2025 15:43:03 +0200 Subject: [PATCH] pan/clc: handle seek-error lseek can return a negative value on error here. While it's not likely to happen, let's add some error-checking here to prevent bad behavior if we're unlucky. CID: 1648299 Reviewed-by: Eric R. Smith Part-of: --- src/panfrost/clc/pan_compile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/panfrost/clc/pan_compile.c b/src/panfrost/clc/pan_compile.c index b80546aaefe..6f88ea9544e 100644 --- a/src/panfrost/clc/pan_compile.c +++ b/src/panfrost/clc/pan_compile.c @@ -285,6 +285,13 @@ main(int argc, const char **argv) } off_t spirv_len = lseek(fd, 0, SEEK_END); + if (spirv_len < 0) { + fprintf(stderr, "Failed to lseek to the end of the file: errno=%d, %s\n", + errno, strerror(errno)); + close(fd); + goto input_spirv_open_failed; + } + const void *spirv_map = mmap(NULL, spirv_len, PROT_READ, MAP_PRIVATE, fd, 0); close(fd);