]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
memory_utils: adapt to new pointer error macros
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 20 Feb 2021 02:17:10 +0000 (03:17 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 20 Feb 2021 02:17:46 +0000 (03:17 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/memory_utils.h

index fb9e1ae4ee04cdb9a5a836de088bfc4d5e399474..fcc51b47821382660ffa25e33057f39df79e247c 100644 (file)
@@ -50,10 +50,12 @@ define_cleanup_function(FILE *, fclose);
 define_cleanup_function(DIR *, closedir);
 #define __do_closedir call_cleaner(closedir)
 
-#define free_disarm(ptr)    \
-       ({                  \
-               free(ptr);  \
-               ptr = NULL; \
+#define free_disarm(ptr)                    \
+       ({                                  \
+               if (!IS_ERR_OR_NULL(ptr)) { \
+                       free(ptr);          \
+                       ptr = NULL;         \
+               }                           \
        })
 
 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)
 {
-       if (list) {
+       if (list && !IS_ERR(list)) {
                for (int i = 0; list[i]; i++)
                        free(list[i]);
                free_disarm(list);