linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: check memory allocation failure
@ 2017-08-23  5:52 Christophe JAILLET
  2017-08-23  8:39 ` Christian König
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2017-08-23  5:52 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, Monk.Liu,
	David1.Zhou, AlexBin.Xie, Jerry.Zhang, airlied, marek.olsak,
	john, andresx7, ray.huang
  Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors, Christophe JAILLET

Check memory allocation failure and return -ENOMEM in such a case.

'num_post_dep_syncobjs' still has to be set to 0 before the test in order
to have it initialized if 'amdgpu_cs_parser_fini()' is called to free
resources.

The calling graph would be, in such a case!
   failure in amdgpu_cs_process_syncobj_out_dep()
      ---> error code returned by amdgpu_cs_dependencies()
         --> amdgpu_cs_parser_fini() is called

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 15d4a28d73bb..baa90df90aea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1079,6 +1079,9 @@ static int amdgpu_cs_process_syncobj_out_dep(struct amdgpu_cs_parser *p,
 					     GFP_KERNEL);
 	p->num_post_dep_syncobjs = 0;
 
+	if (!p->post_dep_syncobjs)
+		return -ENOMEM;
+
 	for (i = 0; i < num_deps; ++i) {
 		p->post_dep_syncobjs[i] = drm_syncobj_find(p->filp, deps[i].handle);
 		if (!p->post_dep_syncobjs[i])
-- 
2.11.0

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

* Re: [PATCH] drm/amdgpu: check memory allocation failure
  2017-08-23  5:52 [PATCH] drm/amdgpu: check memory allocation failure Christophe JAILLET
@ 2017-08-23  8:39 ` Christian König
  2017-08-24 18:23   ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2017-08-23  8:39 UTC (permalink / raw)
  To: Christophe JAILLET, alexander.deucher, airlied, Monk.Liu,
	David1.Zhou, AlexBin.Xie, Jerry.Zhang, airlied, marek.olsak,
	john, andresx7, ray.huang
  Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors

Am 23.08.2017 um 07:52 schrieb Christophe JAILLET:
> Check memory allocation failure and return -ENOMEM in such a case.
>
> 'num_post_dep_syncobjs' still has to be set to 0 before the test in order
> to have it initialized if 'amdgpu_cs_parser_fini()' is called to free
> resources.
>
> The calling graph would be, in such a case!
>     failure in amdgpu_cs_process_syncobj_out_dep()
>        ---> error code returned by amdgpu_cs_dependencies()
>           --> amdgpu_cs_parser_fini() is called
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 15d4a28d73bb..baa90df90aea 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -1079,6 +1079,9 @@ static int amdgpu_cs_process_syncobj_out_dep(struct amdgpu_cs_parser *p,
>   					     GFP_KERNEL);
>   	p->num_post_dep_syncobjs = 0;
>   
> +	if (!p->post_dep_syncobjs)
> +		return -ENOMEM;
> +
>   	for (i = 0; i < num_deps; ++i) {
>   		p->post_dep_syncobjs[i] = drm_syncobj_find(p->filp, deps[i].handle);
>   		if (!p->post_dep_syncobjs[i])

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

* Re: [PATCH] drm/amdgpu: check memory allocation failure
  2017-08-23  8:39 ` Christian König
@ 2017-08-24 18:23   ` Alex Deucher
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2017-08-24 18:23 UTC (permalink / raw)
  To: Christian König
  Cc: Christophe JAILLET, Deucher, Alexander, Dave Airlie, monk.liu,
	Chunming Zhou, Alex Xie, Junwei Zhang, Dave Airlie,
	Marek Olšák, John Brooks, Andres Rodriguez, Huang Rui,
	kernel-janitors, Maling list - DRI developers, amd-gfx list,
	LKML

On Wed, Aug 23, 2017 at 4:39 AM, Christian König
<christian.koenig@amd.com> wrote:
> Am 23.08.2017 um 07:52 schrieb Christophe JAILLET:
>>
>> Check memory allocation failure and return -ENOMEM in such a case.
>>
>> 'num_post_dep_syncobjs' still has to be set to 0 before the test in order
>> to have it initialized if 'amdgpu_cs_parser_fini()' is called to free
>> resources.
>>
>> The calling graph would be, in such a case!
>>     failure in amdgpu_cs_process_syncobj_out_dep()
>>        ---> error code returned by amdgpu_cs_dependencies()
>>           --> amdgpu_cs_parser_fini() is called
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>

Applied.  thanks!

Alex

>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> index 15d4a28d73bb..baa90df90aea 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
>> @@ -1079,6 +1079,9 @@ static int amdgpu_cs_process_syncobj_out_dep(struct
>> amdgpu_cs_parser *p,
>>                                              GFP_KERNEL);
>>         p->num_post_dep_syncobjs = 0;
>>   +     if (!p->post_dep_syncobjs)
>> +               return -ENOMEM;
>> +
>>         for (i = 0; i < num_deps; ++i) {
>>                 p->post_dep_syncobjs[i] = drm_syncobj_find(p->filp,
>> deps[i].handle);
>>                 if (!p->post_dep_syncobjs[i])
>
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-08-24 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23  5:52 [PATCH] drm/amdgpu: check memory allocation failure Christophe JAILLET
2017-08-23  8:39 ` Christian König
2017-08-24 18:23   ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).