2 * Copyright (C) 2023 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 #include "smatch_slist.h"
20 #include "smatch_extra.h"
24 static void match_kobject_function(struct expression
*expr
, const char *name
,
25 struct symbol
*sym
, void *data
)
27 struct sm_state
*sm
, *tmp
;
32 sm
= get_sm_state(SMATCH_EXTRA
, name
, sym
);
36 FOR_EACH_PTR(sm
->possible
, tmp
) {
37 if (rl_max(estate_rl(tmp
->state
)).value
== 0)
38 sm_warning("Calling kobject_put|get with state->initialized unset from line: %d",
40 } END_FOR_EACH_PTR(tmp
);
43 void check_uninitialized_kobj(int id
)
47 if (option_project
!= PROJ_KERNEL
)
50 add_function_param_key_hook("kobject_put", &match_kobject_function
, 0,
51 "$->state_initialized", NULL
);
52 add_function_param_key_hook("kobject_get", &match_kobject_function
, 0,
53 "$->state_initialized", NULL
);