2 * sparse/check_gfp_dma.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 /* this is stolen from the kernel but it's totally fair use dude... */
15 #define __GFP_DMA (0x01u)
16 #define __GFP_HIGHMEM (0x02u)
17 #define __GFP_DMA32 (0x04u)
18 #define __GFP_MOVABLE (0x08u)
19 #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
21 static void match_alloc(const char *fn
, struct expression
*expr
, void *_arg
)
23 int arg_nr
= PTR_INT(_arg
);
24 struct expression
*arg_expr
;
27 arg_expr
= get_argument_from_call_expr(expr
->args
, arg_nr
);
28 if (!get_value(arg_expr
, &val
))
30 if (val
== 0) /* GFP_NOWAIT */
32 if (!(val
& ~GFP_ZONEMASK
))
33 sm_msg("error: no modifiers for allocation.");
36 void check_gfp_dma(int id
)
39 if (option_project
!= PROJ_KERNEL
)
41 add_function_hook("kmalloc", &match_alloc
, INT_PTR(1));
42 add_function_hook("kzalloc", &match_alloc
, INT_PTR(1));