implied: fix get_tf_stacks_from_pool()
[smatch.git] / smatch_kernel_has_devm_cleanup.c
blob9c229515ebd22087552236f970772f54591af30a
1 /*
2 * Copyright (C) 2020 Oracle.
3 * Copyright 2023 Linaro Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 #include "smatch.h"
20 #include "smatch_extra.h"
21 #include "smatch_slist.h"
23 static int my_id;
25 STATE(devm_action);
27 static void ignore_path(const char *fn, struct expression *expr, void *data)
29 set_state(my_id, "path", NULL, &devm_action);
32 bool has_devm_cleanup(void)
34 if (get_state(my_id, "path", NULL) == &devm_action)
35 return true;
36 return false;
39 void register_kernel_has_devm_cleanup(int id)
41 if (option_project != PROJ_KERNEL)
42 return;
44 my_id = id;
46 add_function_hook("devm_add_action_or_reset", &ignore_path, NULL);
47 add_function_hook("__devm_add_action_or_reset", &ignore_path, NULL);
48 add_function_hook("drmm_add_action", &ignore_path, NULL);
49 add_function_hook("__drmm_add_action", &ignore_path, NULL);
50 add_function_hook("drmm_add_action_or_reset", &ignore_path, NULL);
51 add_function_hook("__drmm_add_action_or_reset", &ignore_path, NULL);
52 add_function_hook("pcim_enable_device", &ignore_path, NULL);
53 add_function_hook("pci_enable_device", &ignore_path, NULL);
54 add_function_hook("put_device", &ignore_path, NULL);
55 add_function_hook("component_match_add_release", &ignore_path, NULL);