[PATCH smatch 4/4] smatch: rename PARAM_FREED state to FREED

Harshit Mogalapalli <[email protected]> Wed, 22 Apr 2026 07:32:19 -0700
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
The 1013 free-state info type is currently named PARAM_FREED. That is
misleading because this type is used by free tracking paths beyond
parameter-flow handling.

Rename PARAM_FREED to FREED and update all in-tree users that emit or
consume this info type:
- enum info_type naming in smatch_dbtypes.h
- DB type string mapping in smatch_data/db/smdb.py
- free checker tables and callbacks in smatch_free.c
- free location writes in smatch_free_locations.c
- return-state classification in smatch_free_return_states.c

The numeric type ID is unchanged, so behavior and DB compatibility stay
the same while the terminology is clearer.

Assisted-by: Codex:gpt-5.3-codex
Co-developed-by: Dan Carpenter <[email protected]>
Signed-off-by: Harshit Mogalapalli <[email protected]>
---
 smatch_data/db/smdb.py      |  2 +-
 smatch_dbtypes.h            |  2 +-
 smatch_free.c               | 64 ++++++++++++++++++-------------------
 smatch_free_locations.c     |  2 +-
 smatch_free_return_states.c |  2 +-
 5 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/smatch_data/db/smdb.py b/smatch_data/db/smdb.py
index 33bee1380f5d..7c0f501b61af 100755
--- a/smatch_data/db/smdb.py
+++ b/smatch_data/db/smdb.py
@@ -70,7 +70,7 @@ db_types = {
     1006: "DEREFERENCE",
     1007: "RANGE_CAP",
     1010: "ABSOLUTE_LIMITS",
-    1013: "PARAM_FREED",
+    1013: "FREED",
     2014: "MAYBE_FREED",
     1014: "DATA_SOURCE",
     1015: "FUZZY_MAX",
diff --git a/smatch_dbtypes.h b/smatch_dbtypes.h
index bfdc92b14789..257bd723425c 100644
--- a/smatch_dbtypes.h
+++ b/smatch_dbtypes.h
@@ -20,7 +20,7 @@ enum info_type {
 	DEREFERENCE	= 1006,
 	RANGE_CAP	= 1007,
 	ABSOLUTE_LIMITS	= 1010,
-	PARAM_FREED	= 1013,
+	FREED	= 1013,
 	MAYBE_FREED	= 2014,
 	DATA_SOURCE	= 1014,
 	FUZZY_MAX	= 1015,
diff --git a/smatch_free.c b/smatch_free.c
index 8d9cb70739fd..e8e7bd53f063 100644
--- a/smatch_free.c
+++ b/smatch_free.c
@@ -41,43 +41,43 @@ struct func_info {
 static struct func_info *free_table;
 
 static struct func_info default_func_table[] = {
-	{ "free", PARAM_FREED, 0, "$" },
+	{ "free", FREED, 0, "$" },
 	{ /* sentinel */ }
 };
 
 static struct func_info illumos_func_table[] = {
-	{ "kmem_free", PARAM_FREED, 0, "$" },
+	{ "kmem_free", FREED, 0, "$" },
 	{ /* sentinel */ }
 };
 
 static struct func_info func_table[] = {
-	{ "consume_skb", PARAM_FREED, 0, "$" },
-	{ "brelse", PARAM_FREED, 0, "$" },
-	{ "dma_fence_put", PARAM_FREED, 0, "$" },
-	{ "dma_free_coherent", PARAM_FREED, 2, "$" },
-	{ "dma_pool_free", PARAM_FREED, 1, "$" },
-	{ "enqueue_to_backlog", PARAM_FREED, 0, "$" },
-	{ "free_netdev", PARAM_FREED, 0, "$" },
-	{ "free", PARAM_FREED, 0, "$" },
-	{ "kfree", PARAM_FREED, 0, "$" },
-	{ "kfree_skbmem", PARAM_FREED, 0, "$" },
-	{ "kfree_skb", PARAM_FREED, 0, "$" },
-	{ "kmem_cache_free", PARAM_FREED, 1, "$" },
-	{ "kobject_put", PARAM_FREED, 0, "$", NULL, NULL, &match_kobject_put },
-	{ "kvfree_call_rcu", PARAM_FREED, 1, "$" },
-	{ "kvfree", PARAM_FREED, 0, "$" },
-	{ "kzfree", PARAM_FREED, 0, "$" },
-	{ "mempool_free", PARAM_FREED, 0, "$" },
-	{ "memstick_free_host", PARAM_FREED, 0, "$" },
-	{ "netif_rx_internal", PARAM_FREED, 0, "$" },
-	{ "netif_rx", PARAM_FREED, 0, "$" },
-	{ "put_device", PARAM_FREED, 0, "$", NULL, NULL, &match_kobject_put },
-	{ "qdisc_enqueue", PARAM_FREED, 0, "$" },
-	{ "__skb_pad", PARAM_FREED, 0, "$", &err_min, &err_max, &match___skb_pad },
+	{ "consume_skb", FREED, 0, "$" },
+	{ "brelse", FREED, 0, "$" },
+	{ "dma_fence_put", FREED, 0, "$" },
+	{ "dma_free_coherent", FREED, 2, "$" },
+	{ "dma_pool_free", FREED, 1, "$" },
+	{ "enqueue_to_backlog", FREED, 0, "$" },
+	{ "free_netdev", FREED, 0, "$" },
+	{ "free", FREED, 0, "$" },
+	{ "kfree", FREED, 0, "$" },
+	{ "kfree_skbmem", FREED, 0, "$" },
+	{ "kfree_skb", FREED, 0, "$" },
+	{ "kmem_cache_free", FREED, 1, "$" },
+	{ "kobject_put", FREED, 0, "$", NULL, NULL, &match_kobject_put },
+	{ "kvfree_call_rcu", FREED, 1, "$" },
+	{ "kvfree", FREED, 0, "$" },
+	{ "kzfree", FREED, 0, "$" },
+	{ "mempool_free", FREED, 0, "$" },
+	{ "memstick_free_host", FREED, 0, "$" },
+	{ "netif_rx_internal", FREED, 0, "$" },
+	{ "netif_rx", FREED, 0, "$" },
+	{ "put_device", FREED, 0, "$", NULL, NULL, &match_kobject_put },
+	{ "qdisc_enqueue", FREED, 0, "$" },
+	{ "__skb_pad", FREED, 0, "$", &err_min, &err_max, &match___skb_pad },
 	{ "skb_unshare", IGNORE, 0, "$" },
-	{ "sock_release", PARAM_FREED, 0, "$" },
-//	{ "spi_unregister_controller", PARAM_FREED, 0, "$" },
-	{ "vfree", PARAM_FREED, 0, "$" },
+	{ "sock_release", FREED, 0, "$" },
+//	{ "spi_unregister_controller", FREED, 0, "$" },
+	{ "vfree", FREED, 0, "$" },
 	{ /* sentinel */ }
 };
 
@@ -95,7 +95,7 @@ void add_maybe_free_hook(name_sym_hook *hook)
 
 static void call_free_call_backs_name_sym(int type, struct expression *expr, const char *name, struct symbol *sym)
 {
-	if (type == PARAM_FREED)
+	if (type == FREED)
 		call_name_sym_fns(free_hooks, expr, name, sym);
 	else
 		call_name_sym_fns(maybe_free_hooks, expr, name, sym);
@@ -161,7 +161,7 @@ static void set_param_freed_helper(struct expression *expr, const char *name, st
 
 static void set_param_freed(struct expression *expr, const char *name, struct symbol *sym, void *data)
 {
-	set_param_freed_helper(expr, name, sym, data, PARAM_FREED);
+	set_param_freed_helper(expr, name, sym, data, FREED);
 }
 
 static void set_param_maybe_freed(struct expression *expr, const char *name, struct symbol *sym, void *data)
@@ -207,7 +207,7 @@ static void match___skb_pad(struct expression *expr, const char *name, struct sy
 
 	type = MAYBE_FREED;
 	if (get_implied_value(arg, &sval) && sval.value != 0)
-		type = PARAM_FREED;
+		type = FREED;
 
 	skb = get_argument_from_call_expr(expr->args, 0);
 	call_free_call_backs_expr(type, skb);
@@ -248,6 +248,6 @@ void register_free(int id)
 		}
 	}
 
-	select_return_param_key(PARAM_FREED, &set_param_freed);
+	select_return_param_key(FREED, &set_param_freed);
 	select_return_param_key(MAYBE_FREED, &set_param_maybe_freed);
 }
diff --git a/smatch_free_locations.c b/smatch_free_locations.c
index 03858be3f9a6..afebc49ec0bf 100644
--- a/smatch_free_locations.c
+++ b/smatch_free_locations.c
@@ -68,7 +68,7 @@ static void match_free_member(struct expression *expr, const char *name, struct
 	if (maybe)
 		sql_insert_function_type_info(MAYBE_FREED, type_str, member, fn_name);
 	else
-		sql_insert_function_type_info(PARAM_FREED, type_str, member, fn_name);
+		sql_insert_function_type_info(FREED, type_str, member, fn_name);
 }
 
 static void match_free(struct expression *expr, const char *name, struct symbol *sym)
diff --git a/smatch_free_return_states.c b/smatch_free_return_states.c
index 194b5652c82c..439881ab0a36 100644
--- a/smatch_free_return_states.c
+++ b/smatch_free_return_states.c
@@ -87,7 +87,7 @@ static struct smatch_state *unmatched_state(struct sm_state *sm)
 static int get_freed_type(struct sm_state *sm)
 {
 	if (sm->state == &freed)
-		return PARAM_FREED;
+		return FREED;
 
 	if (slist_has_state(sm->possible, &freed) ||
 	    slist_has_state(sm->possible, &maybe_freed))
-- 
2.47.3