[Mesa-dev] [PATCH v2] util/disk_cache: close a previously opened handle in disk_cache_put (v2)

Mun Gwan-gyeong elongbug at gmail.com
Mon Nov 21 15:21:23 UTC 2016


We're missing the close() to the matching open().

CID 1373407

v2: Fixes from Emil Velikov's review
    Update the teardown in reverse order of the setup/init.

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
 src/util/disk_cache.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 4287878..80dc788 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -612,19 +612,18 @@ disk_cache_put(struct disk_cache *cache,
 
    p_atomic_add(cache->size, size);
 
+ done:
+   if (fd_final != -1)
+      close(fd_final);
    /* This close finally releases the flock, (now that the final dile
     * has been renamed into place and the size has been added).
     */
-   close(fd);
-   fd = -1;
-
- done:
+   if (fd != -1)
+      close(fd);
    if (filename_tmp)
       ralloc_free(filename_tmp);
    if (filename)
       ralloc_free(filename);
-   if (fd != -1)
-      close(fd);
 }
 
 void *
-- 
2.10.2



More information about the mesa-dev mailing list