From 70c42a7008335f5e5db57341a08e6c9aea0b16ff Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 2 Aug 2023 15:38:00 +0300 Subject: [PATCH] checking_for_null_instead_of_err_ptr: silence debugfs warnings Checking debugfs functions for NULL is wrong, but it's also harmless. Don't bother warning about it. Signed-off-by: Dan Carpenter --- check_checking_for_null_instead_of_err_ptr.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/check_checking_for_null_instead_of_err_ptr.c b/check_checking_for_null_instead_of_err_ptr.c index dcbf882f..77e9bfbd 100644 --- a/check_checking_for_null_instead_of_err_ptr.c +++ b/check_checking_for_null_instead_of_err_ptr.c @@ -26,30 +26,38 @@ static const char *untrusted_fn_ptrs[] = { "(struct target_core_fabric_ops)->fabric_make_tpg", "(struct configfs_group_operations)->make_item", "(cgroup_subsys_state)->css_alloc", + /* + * debugfs stuff should not be checked but checking for NULL is harmless + * and some people see the error message and convert it to an IS_ERR() + * check which is buggy. So these warnings introduce a risk. + * + */ + "debugfs_create_dir", + "debugfs_create_file", }; static bool from_untrusted_fn_ptr(struct expression *expr) { struct expression *prev; - char *member_name; bool ret = false; + char *fn; int i; prev = get_assigned_expr(expr); if (!prev || prev->type != EXPR_CALL) return false; - member_name = get_member_name(prev->fn); - if (!member_name) + fn = get_fnptr_name(prev->fn); + if (!fn) return false; for (i = 0; i < ARRAY_SIZE(untrusted_fn_ptrs); i++) { - if (strcmp(member_name, untrusted_fn_ptrs[i]) == 0) { + if (strcmp(fn, untrusted_fn_ptrs[i]) == 0) { ret = true; break; } } - free_string(member_name); + free_string(fn); return ret; } -- 2.11.4.GIT