2019-10-23 08:32:53

by zhongshiqi

[permalink] [raw]
Subject: [PATCH] dc.c:use kzalloc without test

dc.c:583:null check is needed after using kzalloc function

Signed-off-by: zhongshiqi <[email protected]>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 5d1aded..4b8819c 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -580,6 +580,10 @@ static bool construct(struct dc *dc,
#ifdef CONFIG_DRM_AMD_DC_DCN2_0
// Allocate memory for the vm_helper
dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL);
+ if (!dc->vm_helper) {
+ dm_error("%s: failed to create dc->vm_helper\n", __func__);
+ goto fail;
+ }

#endif
memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides));
--
2.9.5


2019-10-23 21:34:53

by Harry Wentland

[permalink] [raw]
Subject: Re: [PATCH] dc.c:use kzalloc without test

On 2019-10-23 4:32 a.m., zhongshiqi wrote:
> dc.c:583:null check is needed after using kzalloc function
>
> Signed-off-by: zhongshiqi <[email protected]>

Reviewed-by: Harry Wentland <[email protected]>

Harry

> ---
> drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
> index 5d1aded..4b8819c 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
> @@ -580,6 +580,10 @@ static bool construct(struct dc *dc,
> #ifdef CONFIG_DRM_AMD_DC_DCN2_0
> // Allocate memory for the vm_helper
> dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL);
> + if (!dc->vm_helper) {
> + dm_error("%s: failed to create dc->vm_helper\n", __func__);
> + goto fail;
> + }
>
> #endif
> memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides));
>

2019-10-25 20:55:33

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] dc.c:use kzalloc without test

Applied. thanks!

Alex

On Wed, Oct 23, 2019 at 9:35 AM Harry Wentland <[email protected]> wrote:
>
> On 2019-10-23 4:32 a.m., zhongshiqi wrote:
> > dc.c:583:null check is needed after using kzalloc function
> >
> > Signed-off-by: zhongshiqi <[email protected]>
>
> Reviewed-by: Harry Wentland <[email protected]>
>
> Harry
>
> > ---
> > drivers/gpu/drm/amd/display/dc/core/dc.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
> > index 5d1aded..4b8819c 100644
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
> > @@ -580,6 +580,10 @@ static bool construct(struct dc *dc,
> > #ifdef CONFIG_DRM_AMD_DC_DCN2_0
> > // Allocate memory for the vm_helper
> > dc->vm_helper = kzalloc(sizeof(struct vm_helper), GFP_KERNEL);
> > + if (!dc->vm_helper) {
> > + dm_error("%s: failed to create dc->vm_helper\n", __func__);
> > + goto fail;
> > + }
> >
> > #endif
> > memcpy(&dc->bb_overrides, &init_params->bb_overrides, sizeof(dc->bb_overrides));
> >
> _______________________________________________
> amd-gfx mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx