[1/2] drm/amdgpu: Fix null ptr when calling query_ras_error_count

Submitted by Andrey Grodzovsky on Aug. 13, 2019, 5:50 p.m.

Details

Message ID 1565718642-18107-1-git-send-email-andrey.grodzovsky@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 2 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Andrey Grodzovsky Aug. 13, 2019, 5:50 p.m.
ras_err_data.err_addr was never allocated

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 50c13b0..d9fb860 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1011,6 +1011,21 @@  static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 	int ret;
 	struct ras_err_data err_data = {0, 0, 0, NULL};
 
+	/* Allocate enough to serve max  number of requests*/
+	int err_addr_size = data->ring_size / data->aligned_element_size *
+			   obj->adev->umc.umc_inst_num *
+			   obj->adev->umc.channel_inst_num;
+
+	err_data.err_addr = kcalloc(err_addr_size,
+				    sizeof(*err_data.err_addr),
+				    GFP_KERNEL);
+
+	if (!err_data.err_addr) {
+		DRM_ERROR("Not enough memory!");
+		return;
+	}
+
+
 	while (data->rptr != data->wptr) {
 		rmb();
 		memcpy(&entry, &data->ring[data->rptr],
@@ -1039,6 +1054,8 @@  static void amdgpu_ras_interrupt_handler(struct ras_manager *obj)
 			}
 		}
 	}
+
+	 kfree(err_data.err_addr);
 }
 
 static void amdgpu_ras_interrupt_process_handler(struct work_struct *work)

Comments

Hi Andrey:

I'm also working on ras error address saving based on your eeprom patches, and the implementation is different from you.
I'll send out my patches this week and we can discuss it.

Regards,
Tao

> -----Original Message-----

> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of

> Andrey Grodzovsky

> Sent: 2019年8月14日 1:51

> To: amd-gfx@lists.freedesktop.org

> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Grodzovsky,

> Andrey <Andrey.Grodzovsky@amd.com>; Pan, Xinhui

> <Xinhui.Pan@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>

> Subject: [PATCH 1/2] drm/amdgpu: Fix null ptr when calling

> query_ras_error_count

> 

> ras_err_data.err_addr was never allocated

> 

> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>

> ---

>  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 17 +++++++++++++++++

>  1 file changed, 17 insertions(+)

> 

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> index 50c13b0..d9fb860 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> @@ -1011,6 +1011,21 @@ static void amdgpu_ras_interrupt_handler(struct

> ras_manager *obj)

>  	int ret;

>  	struct ras_err_data err_data = {0, 0, 0, NULL};

> 

> +	/* Allocate enough to serve max  number of requests*/

> +	int err_addr_size = data->ring_size / data->aligned_element_size *

> +			   obj->adev->umc.umc_inst_num *

> +			   obj->adev->umc.channel_inst_num;

> +

> +	err_data.err_addr = kcalloc(err_addr_size,

> +				    sizeof(*err_data.err_addr),

> +				    GFP_KERNEL);

> +

> +	if (!err_data.err_addr) {

> +		DRM_ERROR("Not enough memory!");

> +		return;

> +	}

> +

> +

>  	while (data->rptr != data->wptr) {

>  		rmb();

>  		memcpy(&entry, &data->ring[data->rptr], @@ -1039,6

> +1054,8 @@ static void amdgpu_ras_interrupt_handler(struct ras_manager

> *obj)

>  			}

>  		}

>  	}

> +

> +	 kfree(err_data.err_addr);

>  }

> 

>  static void amdgpu_ras_interrupt_process_handler(struct work_struct

> *work)

> --

> 2.7.4

> 

> _______________________________________________

> amd-gfx mailing list

> amd-gfx@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Are you referring to this patch which fixes a crash or to the second patch in the serries ?

Andrey
Referring to the series, patch #1 and #2.

Regards,
Tao

> -----Original Message-----

> From: Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>

> Sent: 2019年8月14日 10:42

> To: Zhou1, Tao <Tao.Zhou1@amd.com>; amd-gfx@lists.freedesktop.org

> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Pan, Xinhui

> <Xinhui.Pan@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>

> Subject: Re: [PATCH 1/2] drm/amdgpu: Fix null ptr when calling

> query_ras_error_count

> 

> Are you referring to this patch which fixes a crash or to the second patch in

> the serries ?

> 

> Andrey

> 

> ________________________________________

> From: Zhou1, Tao <Tao.Zhou1@amd.com>

> Sent: 13 August 2019 22:24:00

> To: Grodzovsky, Andrey; amd-gfx@lists.freedesktop.org

> Cc: Deucher, Alexander; Grodzovsky, Andrey; Pan, Xinhui; Zhang, Hawking

> Subject: RE: [PATCH 1/2] drm/amdgpu: Fix null ptr when calling

> query_ras_error_count

> 

> Hi Andrey:

> 

> I'm also working on ras error address saving based on your eeprom patches,

> and the implementation is different from you.

> I'll send out my patches this week and we can discuss it.

> 

> Regards,

> Tao

> 

> > -----Original Message-----

> > From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of

> > Andrey Grodzovsky

> > Sent: 2019年8月14日 1:51

> > To: amd-gfx@lists.freedesktop.org

> > Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Grodzovsky,

> Andrey

> > <Andrey.Grodzovsky@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>;

> Zhang,

> > Hawking <Hawking.Zhang@amd.com>

> > Subject: [PATCH 1/2] drm/amdgpu: Fix null ptr when calling

> > query_ras_error_count

> >

> > ras_err_data.err_addr was never allocated

> >

> > Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>

> > ---

> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 17 +++++++++++++++++

> >  1 file changed, 17 insertions(+)

> >

> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> > index 50c13b0..d9fb860 100644

> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

> > @@ -1011,6 +1011,21 @@ static void

> amdgpu_ras_interrupt_handler(struct

> > ras_manager *obj)

> >       int ret;

> >       struct ras_err_data err_data = {0, 0, 0, NULL};

> >

> > +     /* Allocate enough to serve max  number of requests*/

> > +     int err_addr_size = data->ring_size / data->aligned_element_size *

> > +                        obj->adev->umc.umc_inst_num *

> > +                        obj->adev->umc.channel_inst_num;

> > +

> > +     err_data.err_addr = kcalloc(err_addr_size,

> > +                                 sizeof(*err_data.err_addr),

> > +                                 GFP_KERNEL);

> > +

> > +     if (!err_data.err_addr) {

> > +             DRM_ERROR("Not enough memory!");

> > +             return;

> > +     }

> > +

> > +

> >       while (data->rptr != data->wptr) {

> >               rmb();

> >               memcpy(&entry, &data->ring[data->rptr], @@ -1039,6

> > +1054,8 @@ static void amdgpu_ras_interrupt_handler(struct

> ras_manager

> > *obj)

> >                       }

> >               }

> >       }

> > +

> > +      kfree(err_data.err_addr);

> >  }

> >

> >  static void amdgpu_ras_interrupt_process_handler(struct work_struct

> > *work)

> > --

> > 2.7.4

> >

> > _______________________________________________

> > amd-gfx mailing list

> > amd-gfx@lists.freedesktop.org

> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx