* [PATCH] drm/xe/guc: Fix deference after check
@ 2024-10-08 20:53 Everest K.C.
2024-10-09 8:00 ` Nirmoy Das
0 siblings, 1 reply; 2+ messages in thread
From: Everest K.C. @ 2024-10-08 20:53 UTC (permalink / raw)
To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
mripard, tzimmermann, airlied, simona
Cc: Everest K.C., skhan, intel-xe, dri-devel, kernel-janitors,
linux-kernel
The `if (!snapshot->copy)` evaluates to True only when `snapshot->copy`
is Null. Thus, derefrencing `snapshot->copy` inside this if block is
equivalent to Null pointer derefrencing.
The `if` condition is now changed to evaluate to true only when
`snapshot->copy` is not Null.
This issue was reported by Coverity Scan.
Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
drivers/gpu/drm/xe/xe_guc_log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
index 7fbc56cceaba..4e1a5e8ba1e3 100644
--- a/drivers/gpu/drm/xe/xe_guc_log.c
+++ b/drivers/gpu/drm/xe/xe_guc_log.c
@@ -122,7 +122,7 @@ void xe_guc_log_snapshot_free(struct xe_guc_log_snapshot *snapshot)
if (!snapshot)
return;
- if (!snapshot->copy) {
+ if (snapshot->copy) {
for (i = 0; i < snapshot->num_chunks; i++)
kfree(snapshot->copy[i]);
kfree(snapshot->copy);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/xe/guc: Fix deference after check
2024-10-08 20:53 [PATCH] drm/xe/guc: Fix deference after check Everest K.C.
@ 2024-10-09 8:00 ` Nirmoy Das
0 siblings, 0 replies; 2+ messages in thread
From: Nirmoy Das @ 2024-10-09 8:00 UTC (permalink / raw)
To: Everest K.C., lucas.demarchi, thomas.hellstrom, rodrigo.vivi,
maarten.lankhorst, mripard, tzimmermann, airlied, simona
Cc: skhan, intel-xe, dri-devel, kernel-janitors, linux-kernel
On 10/8/2024 10:53 PM, Everest K.C. wrote:
> The `if (!snapshot->copy)` evaluates to True only when `snapshot->copy`
> is Null. Thus, derefrencing `snapshot->copy` inside this if block is
> equivalent to Null pointer derefrencing.
> The `if` condition is now changed to evaluate to true only when
> `snapshot->copy` is not Null.
> This issue was reported by Coverity Scan.
>
> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
Fixes: d8ce1a977226 ("drm/xe/guc: Use a two stage dump for GuC logs and add more info")
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_log.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
> index 7fbc56cceaba..4e1a5e8ba1e3 100644
> --- a/drivers/gpu/drm/xe/xe_guc_log.c
> +++ b/drivers/gpu/drm/xe/xe_guc_log.c
> @@ -122,7 +122,7 @@ void xe_guc_log_snapshot_free(struct xe_guc_log_snapshot *snapshot)
> if (!snapshot)
> return;
>
> - if (!snapshot->copy) {
> + if (snapshot->copy) {
> for (i = 0; i < snapshot->num_chunks; i++)
> kfree(snapshot->copy[i]);
> kfree(snapshot->copy);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-09 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 20:53 [PATCH] drm/xe/guc: Fix deference after check Everest K.C.
2024-10-09 8:00 ` Nirmoy Das
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox