Skip to contentSkip to conversation

drm/amdkfd: Fix criu_restore_bo error handling

PATCH In review Felix Kuehling 2 participants 2 messages Feb 18, 2022

Subsystems (3)
lore
Share & tools
lore

Felix Kuehling

author maintainer
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix criu_restore_bo error handling

Clang static analysis reports this problem kfd_chardev.c:2327:2: warning: 1st function call argument
is an uninitialized value
kvfree(bo_privs);
^~~~~~~~~~~~~~~~

Make sure bo_buckets and bo_privs are initialized so freeing them in the error handling code path will never result in undefined behaviour.

Fixes 73fa13b6a511 ("drm/amdkfd: CRIU Implement KFD restore ioctl")
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -2
index fead2ed46dc6..ceeb0d5e9060 100644
@@ -2092,8 +2092,8 @@ static int criu_restore_bos(struct kfd_process *p,
 			    uint64_t *priv_offset,
 			    uint64_t max_priv_data_size)
 {
-	struct kfd_criu_bo_bucket *bo_buckets;
-	struct kfd_criu_bo_priv_data *bo_privs;
+	struct kfd_criu_bo_bucket *bo_buckets = NULL;
+	struct kfd_criu_bo_priv_data *bo_privs = NULL;
 	const bool criu_resume = true;
 	bool flush_tlbs = false;
 	int ret = 0, j = 0;
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only]

Regards,
Rajneesh
________________________________
From: Kuehling, Felix <[email protected]>
Sent: Friday, February 18, 2022 5:32:18 PM
To: [email protected] <[email protected]>
Cc: Bhardwaj, Rajneesh <[email protected]>; Tom Rix <[email protected]>
Subject: [PATCH 1/1] drm/amdkfd: Fix criu_restore_bo error handling

Clang static analysis reports this problem kfd_chardev.c:2327:2: warning: 1st function call argument
is an uninitialized value
kvfree(bo_privs);
^~~~~~~~~~~~~~~~

Make sure bo_buckets and bo_privs are initialized so freeing them in the error handling code path will never result in undefined behaviour.

Fixes 73fa13b6a511 ("drm/amdkfd: CRIU Implement KFD restore ioctl")
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -2
index fead2ed46dc6..ceeb0d5e9060 100644
@@ -2092,8 +2092,8 @@ static int criu_restore_bos(struct kfd_process *p,
                             uint64_t *priv_offset,
                             uint64_t max_priv_data_size)
 {
-       struct kfd_criu_bo_bucket *bo_buckets;
-       struct kfd_criu_bo_priv_data *bo_privs;
+       struct kfd_criu_bo_bucket *bo_buckets = NULL;
+       struct kfd_criu_bo_priv_data *bo_privs = NULL;
         const bool criu_resume = true;
         bool flush_tlbs = false;
         int ret = 0, j = 0;

--
2.32.0