drm/dp_mst: Avoid NULL pointer dereference
Subsystems (3)
PATCH 1/1 drm/dp_mst: Avoid NULL pointer dereference
[Why]
Found kernel NULL pointer dereference under the below situation:
src — HDMI_Monitor src — HDMI_Monitor
e.g.: \ =>
MSTB — MSTB (unplug) MSTB — MSTB
When display 1 HDMI and 2 DP daisy chain monitors, unplugging the dp cable connected to source causes kernel NULL pointer dereference at drm_dp_mst_atomic_check_bw_limit(). When calculating pbn_limit, if branch is null, accessing "&branch->ports" causes the problem.
[How]
Judge branch is null or not at the beginning. If it is null, return 0.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
@@ -4707,6 +4707,9 @@ int drm_dp_mst_atomic_check_bw_limit(struct drm_dp_mst_branch *branch,struct drm_dp_vcpi_allocation *vcpi;int pbn_limit =0 , pbn_used =0 ; +if (!branch) +return 0 ; +list_for_each_entry (port, &branch->ports, next) {if (port->mstb)if (drm_dp_mst_atomic_check_bw_limit (port->mstb, mst_state))
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
Thanks for the catch,
From: Wayne Lin <[email protected]>
Sent: Wednesday, December 25, 2019 9:31 PM
To: [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Kazlauskas, Nicholas <[email protected]>; Wentland, Harry <[email protected]>; Lipski, Mikita <[email protected]>; Zuo, Jerry <[email protected]>; [email protected] <[email protected]>;
Lin, Wayne <[email protected]>
Subject: [PATCH] drm/dp_mst: Avoid NULL pointer dereference
[Why]
Found kernel NULL pointer dereference under the below situation:
src — HDMI_Monitor src — HDMI_Monitor
e.g.: \ =>
MSTB — MSTB (unplug) MSTB — MSTB
When display 1 HDMI and 2 DP daisy chain monitors, unplugging the dp
cable connected to source causes kernel NULL pointer dereference at
drm_dp_mst_atomic_check_bw_limit(). When calculating pbn_limit, if
branch is null, accessing "&branch->ports" causes the problem.
[How]
Judge branch is null or not at the beginning. If it is null, return 0.
---
drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++
1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
index 7d2d31eaf003..a6473e3ab448 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4707,6 +4707,9 @@ int drm_dp_mst_atomic_check_bw_limit(struct drm_dp_mst_branch *branch,
struct drm_dp_vcpi_allocation *vcpi;
int pbn_limit = 0, pbn_used = 0;+ if (!branch)
+ return 0;
+
list_for_each_entry(port, &branch->ports, next) {
if (port->mstb)
if (drm_dp_mst_atomic_check_bw_limit(port->mstb, mst_state))--
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Back from the holidays!
Do you need me to push this to drm-misc?
Quoted 38 lines · Wayne Lin
[Why]
Found kernel NULL pointer dereference under the below situation:src —
HDMI_Monitorsrc —HDMI_Monitor
e.g.: \ =>
MSTB — MSTB (unplug) MSTB — MSTBWhen display 1 HDMI and 2 DP daisy chain monitors, unplugging the dp cable connected to source causes kernel NULL pointer dereference at
drm_dp_mst_atomic_check_bw_limit(). When calculatingpbn_limit, if branch is null, accessing "&branch->ports" causes the problem.[How]
Judge branch is null or not at the beginning. If it is null, return 0.Signed-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/drm_dp_mst_topology.c +3
-0@@ -4707,6 +4707,9 @@ int drm_dp_mst_atomic_check_bw_limit(structdrm_dp_mst_branch *branch, struct drm_dp_vcpi_allocation *vcpi;int pbn_limit =0 , pbn_used =0 ; +if (!branch) +return 0 ; +list_for_each_entry (port, &branch->ports, next) {if (port->mstb)if (drm_dp_mst_atomic_check_bw_limit(port->mstb,
mst_state))
Signature · 2 lines
Cheers, Lyude Paul
[AMD Public Use]
Quoted 10 lines
-----原始郵件-----
寄件者: Lyude Paul <[email protected]>
寄件日期: Saturday, January 4, 2020 4:35 AM
收件者: Lin, Wayne <[email protected]>; dri- [email protected]; [email protected] 副本: Kazlauskas, Nicholas <[email protected]>; Wentland, Harry <[email protected]>; Lipski, Mikita <[email protected]>; Zuo, Jerry <[email protected]>; [email protected]
主旨: Re: [PATCH] drm/dp_mst: Avoid NULL pointer dereference
Quoted 6 lines
Back from the holidays!
Reviewed-by Lyude Paul <[email protected]>Do you need me to push this to drm-misc?
Thanks for your time!
And yes, please help to push this to drm-misc.
Quoted 32 lines · Wayne Lin
Quoted 31 lines
[Why]
Found kernel NULL pointer dereference under the below situation:src —
HDMI_Monitorsrc —HDMI_Monitor
e.g.: \ =>
MSTB — MSTB (unplug) MSTB — MSTBWhen display 1 HDMI and 2 DP daisy chain monitors, unplugging the dp cable connected to source causes kernel NULL pointer dereference at
drm_dp_mst_atomic_check_bw_limit(). When calculatingpbn_limit, if branch is null, accessing "&branch->ports" causes the problem.[How]
Judge branch is null or not at the beginning. If it is null, return 0.Signed-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/drm_dp_mst_topology.c +0
-0@@ -4707,6 +4707,9 @@ int drm_dp_mst_atomic_check_bw_limit(structdrm_dp_mst_branch *branch, struct drm_dp_vcpi_allocation *vcpi;int pbn_limit =0 , pbn_used =0 ;
Quoted 10 lines
Quoted 7 lines
drivers/gpu/drm/drm_dp_mst_topology.c +3
-0+if (!branch) +return 0 ; +list_for_each_entry (port, &branch->ports, next) {if (port->mstb)if (drm_dp_mst_atomic_check_bw_limit(port->mstb,
mst_state))--
Cheers,
Lyude Paul
--
Best regards,
Wayne Lin
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx