diff mbox series

[next] drm/xe/guc: Fix inverted logic on snapshot->copy check

Message ID 20241009160510.372195-1-colin.i.king@gmail.com (mailing list archive)
State New, archived
Headers show
Series [next] drm/xe/guc: Fix inverted logic on snapshot->copy check | expand

Commit Message

Colin Ian King Oct. 9, 2024, 4:05 p.m. UTC
Currently the check to see if snapshot->copy has been allocated is
inverted and ends up dereferencing snapshot->copy when free'ing
objects in the array when it is null or not free'ing the objects
when snapshot->copy is allocated. Fix this by using the correct
non-null pointer check logic.

Fixes: d8ce1a977226 ("drm/xe/guc: Use a two stage dump for GuC logs and add more info")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/gpu/drm/xe/xe_guc_log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Harrison Oct. 9, 2024, 4:32 p.m. UTC | #1
On 10/9/2024 09:05, Colin Ian King wrote:
> Currently the check to see if snapshot->copy has been allocated is
> inverted and ends up dereferencing snapshot->copy when free'ing
> objects in the array when it is null or not free'ing the objects
> when snapshot->copy is allocated. Fix this by using the correct
> non-null pointer check logic.
>
> Fixes: d8ce1a977226 ("drm/xe/guc: Use a two stage dump for GuC logs and add more info")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>

Thanks for the fix.

> ---
>   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 93921f04153f..cc70f448d879 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);
Thomas Hellstrom Oct. 10, 2024, 12:57 p.m. UTC | #2
On Wed, 2024-10-09 at 09:32 -0700, John Harrison wrote:
> On 10/9/2024 09:05, Colin Ian King wrote:
> > Currently the check to see if snapshot->copy has been allocated is
> > inverted and ends up dereferencing snapshot->copy when free'ing
> > objects in the array when it is null or not free'ing the objects
> > when snapshot->copy is allocated. Fix this by using the correct
> > non-null pointer check logic.
> > 
> > Fixes: d8ce1a977226 ("drm/xe/guc: Use a two stage dump for GuC logs
> > and add more info")
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
> 
> Thanks for the fix.

Pushed to drm-xe-next. Thanks.

/Thomas



> 
> > ---
> >   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 93921f04153f..cc70f448d879 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);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
index 93921f04153f..cc70f448d879 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);