* [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc()
@ 2025-03-23 12:49 Harshit Mogalapalli
2025-03-23 18:01 ` Christophe JAILLET
2025-03-24 16:57 ` Matthew Brost
0 siblings, 2 replies; 3+ messages in thread
From: Harshit Mogalapalli @ 2025-03-23 12:49 UTC (permalink / raw)
To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Matthew Brost, intel-xe, dri-devel,
linux-kernel
Cc: dan.carpenter, kernel-janitors, error27, harshit.m.mogalapalli
xe_svm_range_alloc() returns ERR_PTR(-ENOMEM) on failure and there is a
dereference of "range" after that:
--> range->gpusvm = gpusvm;
In xe_svm_range_alloc(), when memory allocation fails return NULL
instead to handle this situation.
Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/adaef4dd-5866-48ca-bc22-4a1ddef20381@stanley.mountain/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is based on static analysis and only compile tested.
---
drivers/gpu/drm/xe/xe_svm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index 52e04e7e343f..a79df8cf1f36 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -80,7 +80,7 @@ xe_svm_range_alloc(struct drm_gpusvm *gpusvm)
range = kzalloc(sizeof(*range), GFP_KERNEL);
if (!range)
- return ERR_PTR(-ENOMEM);
+ return NULL;
INIT_LIST_HEAD(&range->garbage_collector_link);
xe_vm_get(gpusvm_to_vm(gpusvm));
--
2.39.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc()
2025-03-23 12:49 [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc() Harshit Mogalapalli
@ 2025-03-23 18:01 ` Christophe JAILLET
2025-03-24 16:57 ` Matthew Brost
1 sibling, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-03-23 18:01 UTC (permalink / raw)
To: Harshit Mogalapalli, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, David Airlie, Simona Vetter, Matthew Brost,
intel-xe, dri-devel, linux-kernel
Cc: dan.carpenter, kernel-janitors, error27
Le 23/03/2025 à 13:49, Harshit Mogalapalli a écrit :
> xe_svm_range_alloc() returns ERR_PTR(-ENOMEM) on failure and there is a
> dereference of "range" after that:
>
> --> range->gpusvm = gpusvm;
>
> In xe_svm_range_alloc(), when memory allocation fails return NULL
> instead to handle this situation.
>
> Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/adaef4dd-5866-48ca-bc22-4a1ddef20381@stanley.mountain/
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is based on static analysis and only compile tested.
> ---
> drivers/gpu/drm/xe/xe_svm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index 52e04e7e343f..a79df8cf1f36 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
> @@ -80,7 +80,7 @@ xe_svm_range_alloc(struct drm_gpusvm *gpusvm)
>
> range = kzalloc(sizeof(*range), GFP_KERNEL);
> if (!range)
> - return ERR_PTR(-ENOMEM);
> + return NULL;
>
> INIT_LIST_HEAD(&range->garbage_collector_link);
> xe_vm_get(gpusvm_to_vm(gpusvm));
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc()
2025-03-23 12:49 [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc() Harshit Mogalapalli
2025-03-23 18:01 ` Christophe JAILLET
@ 2025-03-24 16:57 ` Matthew Brost
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Brost @ 2025-03-24 16:57 UTC (permalink / raw)
To: Harshit Mogalapalli
Cc: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, intel-xe, dri-devel, linux-kernel,
dan.carpenter, kernel-janitors, error27
On Sun, Mar 23, 2025 at 05:49:06AM -0700, Harshit Mogalapalli wrote:
> xe_svm_range_alloc() returns ERR_PTR(-ENOMEM) on failure and there is a
> dereference of "range" after that:
>
> --> range->gpusvm = gpusvm;
>
> In xe_svm_range_alloc(), when memory allocation fails return NULL
> instead to handle this situation.
>
> Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/adaef4dd-5866-48ca-bc22-4a1ddef20381@stanley.mountain/
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> This is based on static analysis and only compile tested.
> ---
> drivers/gpu/drm/xe/xe_svm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index 52e04e7e343f..a79df8cf1f36 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
> @@ -80,7 +80,7 @@ xe_svm_range_alloc(struct drm_gpusvm *gpusvm)
>
> range = kzalloc(sizeof(*range), GFP_KERNEL);
> if (!range)
> - return ERR_PTR(-ENOMEM);
> + return NULL;
>
> INIT_LIST_HEAD(&range->garbage_collector_link);
> xe_vm_get(gpusvm_to_vm(gpusvm));
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-24 16:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-23 12:49 [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc() Harshit Mogalapalli
2025-03-23 18:01 ` Christophe JAILLET
2025-03-24 16:57 ` Matthew Brost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®