13c7b4e6bSCatalin Marinas /* 23c7b4e6bSCatalin Marinas * include/linux/kmemleak.h 33c7b4e6bSCatalin Marinas * 43c7b4e6bSCatalin Marinas * Copyright (C) 2008 ARM Limited 53c7b4e6bSCatalin Marinas * Written by Catalin Marinas <catalin.marinas@arm.com> 63c7b4e6bSCatalin Marinas * 73c7b4e6bSCatalin Marinas * This program is free software; you can redistribute it and/or modify 83c7b4e6bSCatalin Marinas * it under the terms of the GNU General Public License version 2 as 93c7b4e6bSCatalin Marinas * published by the Free Software Foundation. 103c7b4e6bSCatalin Marinas * 113c7b4e6bSCatalin Marinas * This program is distributed in the hope that it will be useful, 123c7b4e6bSCatalin Marinas * but WITHOUT ANY WARRANTY; without even the implied warranty of 133c7b4e6bSCatalin Marinas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 143c7b4e6bSCatalin Marinas * GNU General Public License for more details. 153c7b4e6bSCatalin Marinas * 163c7b4e6bSCatalin Marinas * You should have received a copy of the GNU General Public License 173c7b4e6bSCatalin Marinas * along with this program; if not, write to the Free Software 183c7b4e6bSCatalin Marinas * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 193c7b4e6bSCatalin Marinas */ 203c7b4e6bSCatalin Marinas 213c7b4e6bSCatalin Marinas #ifndef __KMEMLEAK_H 223c7b4e6bSCatalin Marinas #define __KMEMLEAK_H 233c7b4e6bSCatalin Marinas 243c7b4e6bSCatalin Marinas #ifdef CONFIG_DEBUG_KMEMLEAK 253c7b4e6bSCatalin Marinas 263c7b4e6bSCatalin Marinas extern void kmemleak_init(void); 273c7b4e6bSCatalin Marinas extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, 283c7b4e6bSCatalin Marinas gfp_t gfp); 293c7b4e6bSCatalin Marinas extern void kmemleak_free(const void *ptr); 303c7b4e6bSCatalin Marinas extern void kmemleak_padding(const void *ptr, unsigned long offset, 313c7b4e6bSCatalin Marinas size_t size); 323c7b4e6bSCatalin Marinas extern void kmemleak_not_leak(const void *ptr); 333c7b4e6bSCatalin Marinas extern void kmemleak_ignore(const void *ptr); 343c7b4e6bSCatalin Marinas extern void kmemleak_scan_area(const void *ptr, unsigned long offset, 353c7b4e6bSCatalin Marinas size_t length, gfp_t gfp); 363c7b4e6bSCatalin Marinas extern void kmemleak_no_scan(const void *ptr); 373c7b4e6bSCatalin Marinas 383c7b4e6bSCatalin Marinas static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 393c7b4e6bSCatalin Marinas int min_count, unsigned long flags, 403c7b4e6bSCatalin Marinas gfp_t gfp) 413c7b4e6bSCatalin Marinas { 423c7b4e6bSCatalin Marinas if (!(flags & SLAB_NOLEAKTRACE)) 433c7b4e6bSCatalin Marinas kmemleak_alloc(ptr, size, min_count, gfp); 443c7b4e6bSCatalin Marinas } 453c7b4e6bSCatalin Marinas 463c7b4e6bSCatalin Marinas static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 473c7b4e6bSCatalin Marinas { 483c7b4e6bSCatalin Marinas if (!(flags & SLAB_NOLEAKTRACE)) 493c7b4e6bSCatalin Marinas kmemleak_free(ptr); 503c7b4e6bSCatalin Marinas } 513c7b4e6bSCatalin Marinas 523c7b4e6bSCatalin Marinas static inline void kmemleak_erase(void **ptr) 533c7b4e6bSCatalin Marinas { 543c7b4e6bSCatalin Marinas *ptr = NULL; 553c7b4e6bSCatalin Marinas } 563c7b4e6bSCatalin Marinas 573c7b4e6bSCatalin Marinas #else 583c7b4e6bSCatalin Marinas 593c7b4e6bSCatalin Marinas static inline void kmemleak_init(void) 603c7b4e6bSCatalin Marinas { 613c7b4e6bSCatalin Marinas } 623c7b4e6bSCatalin Marinas static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count, 633c7b4e6bSCatalin Marinas gfp_t gfp) 643c7b4e6bSCatalin Marinas { 653c7b4e6bSCatalin Marinas } 663c7b4e6bSCatalin Marinas static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 673c7b4e6bSCatalin Marinas int min_count, unsigned long flags, 683c7b4e6bSCatalin Marinas gfp_t gfp) 693c7b4e6bSCatalin Marinas { 703c7b4e6bSCatalin Marinas } 713c7b4e6bSCatalin Marinas static inline void kmemleak_free(const void *ptr) 723c7b4e6bSCatalin Marinas { 733c7b4e6bSCatalin Marinas } 743c7b4e6bSCatalin Marinas static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 753c7b4e6bSCatalin Marinas { 763c7b4e6bSCatalin Marinas } 773c7b4e6bSCatalin Marinas static inline void kmemleak_not_leak(const void *ptr) 783c7b4e6bSCatalin Marinas { 793c7b4e6bSCatalin Marinas } 803c7b4e6bSCatalin Marinas static inline void kmemleak_ignore(const void *ptr) 813c7b4e6bSCatalin Marinas { 823c7b4e6bSCatalin Marinas } 833c7b4e6bSCatalin Marinas static inline void kmemleak_scan_area(const void *ptr, unsigned long offset, 843c7b4e6bSCatalin Marinas size_t length, gfp_t gfp) 853c7b4e6bSCatalin Marinas { 863c7b4e6bSCatalin Marinas } 873c7b4e6bSCatalin Marinas static inline void kmemleak_erase(void **ptr) 883c7b4e6bSCatalin Marinas { 893c7b4e6bSCatalin Marinas } 903c7b4e6bSCatalin Marinas static inline void kmemleak_no_scan(const void *ptr) 913c7b4e6bSCatalin Marinas { 923c7b4e6bSCatalin Marinas } 933c7b4e6bSCatalin Marinas 943c7b4e6bSCatalin Marinas #endif /* CONFIG_DEBUG_KMEMLEAK */ 953c7b4e6bSCatalin Marinas 963c7b4e6bSCatalin Marinas #endif /* __KMEMLEAK_H */ 97