Skip to contentSkip to conversation

amdgpu/dc: handle allocation failures in dc_commit_planes_to_stream.

PATCH In review Dave Airlie 3 participants 3 messages Nov 6, 2017 – Nov 7, 2017 2 messages not in the archive

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

PATCH 1/1 amdgpu/dc: handle allocation failures in dc_commit_planes_to_stream.

From: Dave Airlie <[email protected]>

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)

---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +8 -0
index a71392f..ce3c57b 100644
@@ -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;
Signature · 6 lines
2.9.5

_______________________________________________
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): 20171106192118.24084-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 21 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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)

---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -0
index a71392f..ce3c57b 100644
@@ -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) {

drivers/gpu/drm/amd/display/dc/core/dc.c bool dc_commit_planes_to_stream( · line 965

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +7 -0
+		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;

_______________________________________________
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): ff1e489c-9bec-45cd-9d24-c7a6e1aa26d7-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#4 lore raw
Quoted 12 lines · Andrey Grodzovsky
Quoted 8 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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)

Harry

Quoted 18 lines
Quoted 18 lines

---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 8 ++++++++

  1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +6 -0
index a71392f..ce3c57b 100644
@@ -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;
+    }
Quoted 8 lines

drivers/gpu/drm/amd/display/dc/core/dc.c bool dc_commit_planes_to_stream( · line 965

Quoted 3 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -0
+
       memset(updates, 0, sizeof(updates));
         stream_update->src = dc_stream->src;

_______________________________________________
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