user_data: the pointer returned from container_of() is ok
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 15 Mar 2013 14:46:55 +0000 (15 17:46 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Fri, 15 Mar 2013 14:46:55 +0000 (15 17:46 +0300)
Normally if we do math the result is a user macro, but from container_of()
it's probably not.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_user_data.c

index ef486ae..283868a 100644 (file)
@@ -115,6 +115,19 @@ free:
        return ret;
 }
 
+static int in_container_of_macro(struct expression *expr)
+{
+       char *macro;
+
+       macro = get_macro_name(expr->pos);
+
+       if (!macro)
+               return 0;
+       if (strcmp(macro, "container_of") == 0)
+               return 1;
+       return 0;
+}
+
 int is_user_data(struct expression *expr)
 {
        struct state_list *slist = NULL;
@@ -128,6 +141,8 @@ int is_user_data(struct expression *expr)
 
        if (is_capped(expr))
                return 0;
+       if (in_container_of_macro(expr))
+               return 0;
 
        if (is_user_macro(expr))
                return 1;