diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-09-05 14:09:10 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-09-05 14:09:10 +0000 |
commit | cf6ad756ad4ecfd8fe0d1ffb0c78c4d3826d3c22 (patch) | |
tree | 783b9677210fe6dbb47ca0024e08df42fcb98fc5 /sys/dev | |
parent | 96e07f8fadf6c4a0a2099d8733182ab6ef998b53 (diff) |
drm/amd/display: Avoid MPC infinite loop
From Josip Pavic
0c8abeceee0f58ad3fdc66e1de0c0e02b962653b in linux 5.15.y/5.15.65
8de297dc046c180651c0500f8611663ae1c3828a in mainline linux
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_mpc.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_mpc.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_mpc.c b/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_mpc.c index 11019c2c62c..8192f1967e9 100644 --- a/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_mpc.c +++ b/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_mpc.c @@ -126,6 +126,12 @@ struct mpcc *mpc1_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) while (tmp_mpcc != NULL) { if (tmp_mpcc->dpp_id == dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); + if (tmp_mpcc == tmp_mpcc->mpcc_bot) + break; + tmp_mpcc = tmp_mpcc->mpcc_bot; } return NULL; diff --git a/sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_mpc.c b/sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_mpc.c index 947eb0df3f1..142fc0a3a53 100644 --- a/sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_mpc.c +++ b/sys/dev/pci/drm/amd/display/dc/dcn20/dcn20_mpc.c @@ -532,6 +532,12 @@ struct mpcc *mpc2_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) while (tmp_mpcc != NULL) { if (tmp_mpcc->dpp_id == 0xf || tmp_mpcc->dpp_id == dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); + if (tmp_mpcc == tmp_mpcc->mpcc_bot) + break; + tmp_mpcc = tmp_mpcc->mpcc_bot; } return NULL; |