container_of: people checking the return value of nla_data() are wrong
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 16 Sep 2013 09:30:42 +0000 (16 12:30 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 16 Sep 2013 09:30:42 +0000 (16 12:30 +0300)
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 <dan.carpenter@oracle.com>
check_container_of.c

index c07799e..2109499 100644 (file)
@@ -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);
 }