]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
amdgpu/dc: handle allocation failures in dc_commit_planes_to_stream.
authorDave Airlie <airlied@redhat.com>
Mon, 6 Nov 2017 19:21:18 +0000 (05:21 +1000)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 7 Nov 2017 21:22:08 +0000 (16:22 -0500)
Reported-by smatch:
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:966 dc_commit_planes_to_stream() error: potential null dereference 'flip_addr'.  (kcalloc returns null)
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:968 dc_commit_planes_to_stream() error: potential null dereference 'plane_info'.  (kcalloc returns null)
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:978 dc_commit_planes_to_stream() error: potential null dereference 'scaling_info'.  (kcalloc returns null)

Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c

index a71392ffc46d5cdf02f1a6a9c837fd115e589dcf..ce3c57b38bc0678471ba59bb057567d2704f8b3c 100644 (file)
@@ -952,6 +952,14 @@ bool dc_commit_planes_to_stream(
        scaling_info = kcalloc(MAX_SURFACES, sizeof(struct dc_scaling_info),
                               GFP_KERNEL);
 
+       if (!flip_addr || !plane_info || !scaling_info) {
+               kfree(flip_addr);
+               kfree(plane_info);
+               kfree(scaling_info);
+               kfree(stream_update);
+               return false;
+       }
+
        memset(updates, 0, sizeof(updates));
 
        stream_update->src = dc_stream->src;