Skip to contentSkip to conversation

amd/display: Fix potential null dereference in dce_calcs.c

PATCH In review Ernst Sjöstrand 2 participants 2 messages Nov 8, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 amd/display: Fix potential null dereference in dce_calcs.c

Reported by smatch:
bw_calcs() error: potential null dereference 'data'

---
I couldn't use DC_ERROR because the dc_context had the wrong variable name. Seems like a larger project to fix...

 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -0
index 4f8a95368ffc..6347712db834 100644
@@ -2794,6 +2794,8 @@ bool bw_calcs(struct dc_context *ctx,
 {
 	struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data),
 					     GFP_KERNEL);
+	if (!data)
+		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): 20171108214706.5579-1-ernstp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 4 lines · Ernst Sjöstrand

Reported by smatch:
bw_calcs() error: potential null dereference 'data'

Reviewed and pushed. thanks!

Alex

Quoted 23 lines

---
I couldn't use DC_ERROR because the dc_context had the wrong variable name. Seems like a larger project to fix...

 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +2 -1
index 4f8a95368ffc..6347712db834 100644
@@ -2794,6 +2794,8 @@ bool bw_calcs(struct dc_context *ctx,
 {
        struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data),
                                             GFP_KERNEL);
+       if (!data)
+               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