diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index dc58254a2b696a9ee38c384845481632ab25c236..8c01b2cfdb1adb6db33ddea36529a1c69d668a70 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -22,7 +22,7 @@ static inline void *zalloc(size_t size)
 	return calloc(1, size);
 }
 
-#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
+#define zfree(ptr) ({ free((void *)*ptr); *ptr = NULL; })
 
 struct dirent;
 struct nsinfo;