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

Ernst Sjöstrand ernstp at gmail.com
Wed Nov 8 20:17:03 UTC 2017


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

Signed-off-by: Ernst Sjöstrand <ernstp at gmail.com>
---
 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
index 4f8a95368ffc..64a885195208 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
@@ -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);
 
-- 
2.14.1



More information about the amd-gfx mailing list