From: Dan Carpenter Date: Mon, 16 Sep 2013 09:30:42 +0000 (+0300) Subject: container_of: people checking the return value of nla_data() are wrong X-Git-Tag: 1.60~524 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/c42b63359e9aef42ca34c2d42e67ad353acaf9d1 container_of: people checking the return value of nla_data() are wrong There is no way that checking the return value of nla_data() makes sense. People sometimes check it out of a reflex for checking every return value which is normally harmless. But sometimes they actually intended to check something else and it leads to a bad dereference. Signed-off-by: Dan Carpenter --- diff --git a/check_container_of.c b/check_container_of.c index c07799eb..2109499e 100644 --- a/check_container_of.c +++ b/check_container_of.c @@ -54,6 +54,7 @@ void check_container_of(int id) my_id = id; add_macro_assign_hook("container_of", &match_non_null, NULL); add_macro_assign_hook("list_first_entry", &match_non_null, NULL); + add_function_assign_hook("nla_data", &match_non_null, NULL); add_modification_hook(my_id, &is_ok); add_hook(&match_condition, CONDITION_HOOK); }