]> rtime.felk.cvut.cz Git - jailhouse.git/blob - ci/coverity_model.c
ci: Add Coverity model for kmalloc
[jailhouse.git] / ci / coverity_model.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2015
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #define __MODEL_GFP_USER        (0x10u | 0x40u | 0x80u | 0x20000u)
14 #define __MODEL_GFP_NOWARN      0x200u
15
16 void *kmalloc(size_t size, unsigned flags)
17 {
18         void *ptr;
19
20         if (flags == (__MODEL_GFP_USER | __MODEL_GFP_NOWARN))
21                 __coverity_tainted_data_sanitize__(size);
22         else
23                 __coverity_tainted_data_sink__(size);
24
25         ptr = __coverity_alloc__(size);
26
27         __coverity_mark_as_uninitialized_buffer__(ptr);
28         __coverity_mark_as_afm_allocated__(ptr, "kfree");
29
30         return ptr;
31 }