From ed779170a16dbd1c01d62aa0b1eae67f4c2e0b7b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 15 Mar 2013 17:46:55 +0300 Subject: [PATCH] user_data: the pointer returned from container_of() is ok Normally if we do math the result is a user macro, but from container_of() it's probably not. Signed-off-by: Dan Carpenter --- check_user_data.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/check_user_data.c b/check_user_data.c index ef486aed..283868ab 100644 --- a/check_user_data.c +++ b/check_user_data.c @@ -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; -- 2.11.4.GIT