memory_utils: adapt to new pointer error macros

parent 75f08c85
...@@ -50,10 +50,12 @@ define_cleanup_function(FILE *, fclose); ...@@ -50,10 +50,12 @@ define_cleanup_function(FILE *, fclose);
define_cleanup_function(DIR *, closedir); define_cleanup_function(DIR *, closedir);
#define __do_closedir call_cleaner(closedir) #define __do_closedir call_cleaner(closedir)
#define free_disarm(ptr) \ #define free_disarm(ptr) \
({ \ ({ \
free(ptr); \ if (!IS_ERR_OR_NULL(ptr)) { \
ptr = NULL; \ free(ptr); \
ptr = NULL; \
} \
}) })
static inline void free_disarm_function(void *ptr) static inline void free_disarm_function(void *ptr)
...@@ -64,7 +66,7 @@ static inline void free_disarm_function(void *ptr) ...@@ -64,7 +66,7 @@ static inline void free_disarm_function(void *ptr)
static inline void free_string_list(char **list) static inline void free_string_list(char **list)
{ {
if (list) { if (list && !IS_ERR(list)) {
for (int i = 0; list[i]; i++) for (int i = 0; list[i]; i++)
free(list[i]); free(list[i]);
free_disarm(list); free_disarm(list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment