amd/display: Fix potential null dereference in dce_calcs.c
Subsystems (3)
PATCH 1/1 amd/display: Fix potential null dereference in dce_calcs.c
Reported by smatch:bw_calcs() error: potential null dereference 'data'
--- drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +4 -0
@@ -2794,6 +2794,10 @@ bool bw_calcs(struct dc_context *ctx, {struct bw_calcs_data *data =kzalloc (sizeof (struct bw_calcs_data ),GFP_KERNEL ); +if (!data) { +DRM_ERROR ("Failed to allocate bw_calcs_data\n" ); +return false; + }populate_initial_data (pipe, pipe_count, data);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20171108201703.27467-1-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 21 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Ernst Sjöstrand
Sent: Wednesday, November 08, 2017 3:17 PM
To: [email protected]
Subject: [PATCH] amd/display: Fix potential null dereference indce_calcs.cReported by smatch:
bw_calcs()error: potential null dereference 'data'Signed-off-by Ernst Sjöstrand <[email protected]>--- drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +0
-0
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c bool bw_calcs(struct dc_context *ctx, · line 2798
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2
-0@@ -2794,6 +2794,10 @@ bool bw_calcs(struct dc_context *ctx, {struct bw_calcs_data *data =kzalloc (sizeof (struct bw_calcs_data ),GFP_KERNEL ); +if (!data) { +DRM_ERROR ("Failed to allocate bw_calcs_data\n" );
I think we are trying to keep DRM specifics out of dc as much as possible so drop the error message and just return false.
Thanks!
Alex
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2
-1+return false; + }populate_initial_data (pipe, pipe_count, data); --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB16527CF3D43670B4E2E340CAF7560-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 15 lines · Alexander
Quoted 15 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Ernst Sjöstrand
Sent: Wednesday, November 08, 2017 3:17 PM
To: [email protected]
Subject: [PATCH] amd/display: Fix potential null dereference indce_calcs.cReported by smatch:
bw_calcs()error: potential null dereference 'data'Signed-off-by Ernst Sjöstrand <[email protected]>--- drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 14 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c bool bw_calcs(struct dc_context *ctx, · line 2798
Quoted 11 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2
-0@@ -2794,6 +2794,10 @@ bool bw_calcs(struct dc_context *ctx, {struct bw_calcs_data *data =kzalloc (sizeof (struct bw_calcs_data ),GFP_KERNEL ); +if (!data) { +DRM_ERROR ("Failed to allocate bw_calcs_data\n" );I think we are trying to keep DRM specifics out of dc as much as possible so drop the error message and just return false.
Alternatively use DC_ERROR() to log, just like you would with DRM_ERROR.
Note that if you trace it you'll go down the rabbit hole that's the DC logger. It's still on our list to clean up and route more directly to kernel logging functionality. A task for that is in amd/display/TODO.
Thanks for the patch.
Harry
Quoted 12 lines
Thanks!
Alex
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2
-1+return false; + }populate_initial_data (pipe, pipe_count, data); --2.14.1
Quoted 9 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx