All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: fix freeing an unset pointer
@ 2022-02-09 14:52 ` trix
  0 siblings, 0 replies; 4+ messages in thread
From: trix @ 2022-02-09 14:52 UTC (permalink / raw)
  To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, david.yatsin,
	rajneesh.bhardwaj
  Cc: amd-gfx, dri-devel, linux-kernel, llvm, Tom Rix

From: Tom Rix <trix@redhat.com>

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

When bo_buckets alloc fails, it jumps to an error handler
that frees the yet to be allocated bo_privs.  Because
bo_buckets is the first error, return directly.

Fixes: 5ccbb057c0a1 ("drm/amdkfd: CRIU Implement KFD checkpoint ioctl")

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 64e3b4e3a7126..636391c61cafb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1982,10 +1982,8 @@ static int criu_checkpoint_bos(struct kfd_process *p,
 	void *mem;
 
 	bo_buckets = kvzalloc(num_bos * sizeof(*bo_buckets), GFP_KERNEL);
-	if (!bo_buckets) {
-		ret = -ENOMEM;
-		goto exit;
-	}
+	if (!bo_buckets)
+		return -ENOMEM;
 
 	bo_privs = kvzalloc(num_bos * sizeof(*bo_privs), GFP_KERNEL);
 	if (!bo_privs) {
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] drm/amdkfd: fix freeing an unset pointer
@ 2022-02-09 14:52 ` trix
  0 siblings, 0 replies; 4+ messages in thread
From: trix @ 2022-02-09 14:52 UTC (permalink / raw)
  To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, david.yatsin,
	rajneesh.bhardwaj
  Cc: Tom Rix, llvm, dri-devel, amd-gfx, linux-kernel

From: Tom Rix <trix@redhat.com>

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

When bo_buckets alloc fails, it jumps to an error handler
that frees the yet to be allocated bo_privs.  Because
bo_buckets is the first error, return directly.

Fixes: 5ccbb057c0a1 ("drm/amdkfd: CRIU Implement KFD checkpoint ioctl")

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 64e3b4e3a7126..636391c61cafb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1982,10 +1982,8 @@ static int criu_checkpoint_bos(struct kfd_process *p,
 	void *mem;
 
 	bo_buckets = kvzalloc(num_bos * sizeof(*bo_buckets), GFP_KERNEL);
-	if (!bo_buckets) {
-		ret = -ENOMEM;
-		goto exit;
-	}
+	if (!bo_buckets)
+		return -ENOMEM;
 
 	bo_privs = kvzalloc(num_bos * sizeof(*bo_privs), GFP_KERNEL);
 	if (!bo_privs) {
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: fix freeing an unset pointer
  2022-02-09 14:52 ` trix
@ 2022-02-09 20:34   ` Felix Kuehling
  -1 siblings, 0 replies; 4+ messages in thread
From: Felix Kuehling @ 2022-02-09 20:34 UTC (permalink / raw)
  To: trix, alexander.deucher, christian.koenig, Xinhui.Pan, airlied,
	daniel, nathan, ndesaulniers, david.yatsin, rajneesh.bhardwaj
  Cc: llvm, dri-devel, amd-gfx, linux-kernel


On 2022-02-09 09:52, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis reports this problem
> kfd_chardev.c:2092:2: warning: 1st function call argument
>    is an uninitialized value
>          kvfree(bo_privs);
>          ^~~~~~~~~~~~~~~~
>
> When bo_buckets alloc fails, it jumps to an error handler
> that frees the yet to be allocated bo_privs.  Because
> bo_buckets is the first error, return directly.
>
> Fixes: 5ccbb057c0a1 ("drm/amdkfd: CRIU Implement KFD checkpoint ioctl")

Thank you, Tom. I'm applying your patch to amd-staging-drm-next.

Regards,
   Felix


>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 64e3b4e3a7126..636391c61cafb 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1982,10 +1982,8 @@ static int criu_checkpoint_bos(struct kfd_process *p,
>   	void *mem;
>   
>   	bo_buckets = kvzalloc(num_bos * sizeof(*bo_buckets), GFP_KERNEL);
> -	if (!bo_buckets) {
> -		ret = -ENOMEM;
> -		goto exit;
> -	}
> +	if (!bo_buckets)
> +		return -ENOMEM;
>   
>   	bo_privs = kvzalloc(num_bos * sizeof(*bo_privs), GFP_KERNEL);
>   	if (!bo_privs) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: fix freeing an unset pointer
@ 2022-02-09 20:34   ` Felix Kuehling
  0 siblings, 0 replies; 4+ messages in thread
From: Felix Kuehling @ 2022-02-09 20:34 UTC (permalink / raw)
  To: trix, alexander.deucher, christian.koenig, Xinhui.Pan, airlied,
	daniel, nathan, ndesaulniers, david.yatsin, rajneesh.bhardwaj
  Cc: amd-gfx, dri-devel, linux-kernel, llvm


On 2022-02-09 09:52, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis reports this problem
> kfd_chardev.c:2092:2: warning: 1st function call argument
>    is an uninitialized value
>          kvfree(bo_privs);
>          ^~~~~~~~~~~~~~~~
>
> When bo_buckets alloc fails, it jumps to an error handler
> that frees the yet to be allocated bo_privs.  Because
> bo_buckets is the first error, return directly.
>
> Fixes: 5ccbb057c0a1 ("drm/amdkfd: CRIU Implement KFD checkpoint ioctl")

Thank you, Tom. I'm applying your patch to amd-staging-drm-next.

Regards,
   Felix


>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 64e3b4e3a7126..636391c61cafb 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -1982,10 +1982,8 @@ static int criu_checkpoint_bos(struct kfd_process *p,
>   	void *mem;
>   
>   	bo_buckets = kvzalloc(num_bos * sizeof(*bo_buckets), GFP_KERNEL);
> -	if (!bo_buckets) {
> -		ret = -ENOMEM;
> -		goto exit;
> -	}
> +	if (!bo_buckets)
> +		return -ENOMEM;
>   
>   	bo_privs = kvzalloc(num_bos * sizeof(*bo_privs), GFP_KERNEL);
>   	if (!bo_privs) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-09 20:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 14:52 [PATCH] drm/amdkfd: fix freeing an unset pointer trix
2022-02-09 14:52 ` trix
2022-02-09 20:34 ` Felix Kuehling
2022-02-09 20:34   ` Felix Kuehling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.