Mesa (staging/20.0): util/disk_cache: check for write() failure in the zstd path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 5 17:05:47 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: ccf70209d2880e53203e792a565b48943ec284e0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccf70209d2880e53203e792a565b48943ec284e0

Author: Eric Engestrom <eric at engestrom.ch>
Date:   Sun Feb  2 17:15:09 2020 +0000

util/disk_cache: check for write() failure in the zstd path

CoverityID: 1458074
Fixes: a8d941091f72923561a6 ("util: Use ZSTD for shader cache if possible")
Signed-off-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3672>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3672>
(cherry picked from commit 2799676218249c5b9f1dc0a6367e459a1ad5642e)

---

 .pick_status.json     | 2 +-
 src/util/disk_cache.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 92d4b85f3f9..2922bfb5d6a 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -157,7 +157,7 @@
         "description": "util/disk_cache: check for write() failure in the zstd path",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "a8d941091f72923561a6c58b46ccb264b6a0e205"
     },
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index e5b21b9a79f..d1f14736725 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -758,7 +758,11 @@ deflate_and_write_to_disk(const void *in_data, size_t in_data_size, int dest,
       free(out);
       return 0;
    }
-   write_all(dest, out, ret);
+   ssize_t written = write_all(dest, out, ret);
+   if (written == -1) {
+      free(out);
+      return 0;
+   }
    free(out);
    return ret;
 #else



More information about the mesa-commit mailing list