From 2df306923a2b09aa6e46a3e24e9b0335c8016a1d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 13 Aug 2021 06:32:44 -0400 Subject: [PATCH] file_internal.c guard file_cache_reset() from null pointer I feel this is probably unlikely to be called with a NULL pointer for cachep but being that we are already doing the check why not guard file_cache_reset as well Change-Id: I1a13767ef28a4129ae3513f7aa999fb6c1d6fad8 --- firmware/common/file_internal.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/firmware/common/file_internal.c b/firmware/common/file_internal.c index 5f35e35abc..b92c4ea115 100644 --- a/firmware/common/file_internal.c +++ b/firmware/common/file_internal.c @@ -75,13 +75,15 @@ void file_cache_alloc(struct filestr_cache *cachep) /* free resources attached to the cache */ void file_cache_free(struct filestr_cache *cachep) { - if (cachep && cachep->buffer) + if (cachep) { - dc_release_buffer(cachep->buffer); - cachep->buffer = NULL; + if(cachep->buffer) + { + dc_release_buffer(cachep->buffer); + cachep->buffer = NULL; + } + file_cache_reset(cachep); } - - file_cache_reset(cachep); }