]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/ras: Remove redundant NULL check in pending bad-bank list iteration
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Sun, 15 Mar 2026 06:23:31 +0000 (11:53 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 23 Mar 2026 18:02:58 +0000 (14:02 -0400)
ras_umc_log_pending_bad_bank() walks through a list of pending ECC
bad-bank entries. These entries are saved when a bad-bank error cannot
be processed immediately, for example during a GPU reset.

Later, this function iterates over the pending list and retries logging
each bad-bank error. If logging succeeds, the entry is removed from the
list and the memory for that node is freed.

The loop uses list_for_each_entry_safe(), which already guarantees that
ecc_node points to a valid list entry while the loop body is executing.

Checking "ecc_node &&" inside the loop is therefore unnecessary and
redundant.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras_umc.c:225 ras_umc_log_pending_bad_bank() warn: variable dereferenced before check 'ecc_node' (see line 223)

Fixes: 7a3f9c0992c4 ("drm/amd/ras: Add umc common ras functions")
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: YiPeng Chai <YiPeng.Chai@amd.com>
Cc: Tao Zhou <tao.zhou1@amd.com>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: YiPeng Chai <YiPeng.Chai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/ras/rascore/ras_umc.c

index 23118f41eb96f5d7a6e27fade80f79519b582237..c7ae005ea70525059cf86a59c5b990924eec1a96 100644 (file)
@@ -222,7 +222,7 @@ int ras_umc_log_pending_bad_bank(struct ras_core_context *ras_core)
        mutex_lock(&ras_umc->pending_ecc_lock);
        list_for_each_entry_safe(ecc_node,
                tmp, &ras_umc->pending_ecc_list, node){
-               if (ecc_node && !ras_umc_log_bad_bank(ras_core, &ecc_node->ecc)) {
+               if (!ras_umc_log_bad_bank(ras_core, &ecc_node->ecc)) {
                        list_del(&ecc_node->node);
                        kfree(ecc_node);
                }