From 6954b6fdbbe8ab6e6cdf1f39b7477ded6f9c06c3 Mon Sep 17 00:00:00 2001 From: zhangyuyang Date: Mon, 22 Dec 2025 08:58:43 +0800 Subject: [PATCH] drivers:misc:sdma-dae: add NULL judgement of global variables kunpeng inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDGUM6 CVE: NA ---------------------------------------------------------------------- 1. add NULL judgement before using global variables. Fixes: b53053d5679d ("driver:misc:sdma-dae: add debugfs of sdma-dae") Signed-off-by: zhangyuyang --- drivers/misc/sdma-dae/sdma_auth.c | 6 ++++++ drivers/misc/sdma-dae/sdma_umem.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/misc/sdma-dae/sdma_auth.c b/drivers/misc/sdma-dae/sdma_auth.c index 6b6585a2e807..e634ef01e198 100644 --- a/drivers/misc/sdma-dae/sdma_auth.c +++ b/drivers/misc/sdma-dae/sdma_auth.c @@ -58,6 +58,9 @@ void sdma_authority_ht_free(void) struct hlist_node *tmp; u32 bkt; + if (g_authority == NULL) + return; + write_lock(&g_authority->owner_pid_lock); hash_for_each_safe(g_authority->sdma_owner_pid_ht, bkt, tmp, entry, node) entry_free_pid_ht(entry); @@ -87,6 +90,9 @@ void sdma_free_authority_ht_with_pid(u32 pid) struct hlist_node *tmp; u32 bkt; + if (g_authority == NULL) + return; + write_lock(&g_authority->owner_pid_lock); hash_for_each_safe(g_authority->sdma_owner_pid_ht, bkt, tmp, entry, node) { if (entry->pid == pid) diff --git a/drivers/misc/sdma-dae/sdma_umem.c b/drivers/misc/sdma-dae/sdma_umem.c index 55d687160af2..ba9424f854fa 100644 --- a/drivers/misc/sdma-dae/sdma_umem.c +++ b/drivers/misc/sdma-dae/sdma_umem.c @@ -66,6 +66,9 @@ void sdma_hash_free_entry(int key) struct hash_entry *entry; struct hlist_node *node_tmp; + if (g_hash_table == NULL) + return; + pr_debug("Function %s: free ida %d\n", __func__, key); spin_lock(&g_hash_table->hash_lock); @@ -82,6 +85,9 @@ void sdma_hash_free(void) struct hlist_node *tmp; u32 bkt; + if (g_hash_table == NULL) + return; + spin_lock(&g_hash_table->hash_lock); hash_for_each_safe(g_hash_table->sdma_fd_ht, bkt, tmp, entry, node) -- Gitee