drm/plane: Move range check for format_count earlier
Subsystems (2)
PATCH 1/1 drm/plane: Move range check for format_count earlier
While the check for format_count > 64 in __drm_universal_plane_init() shouldn't be hit (it's a WARN_ON), in its current position it will then leak the plane->format_types array and fail to call drm_mode_object_unregister() leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place.
--- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_plane.c +7 -7
@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,if (WARN_ON (config->num_total_plane >=32 ))return -EINVAL ; +/* +* First driver to need more than 64 formats needs to fix this. Each +* format is encoded as a bit and the current code only supports a u64. +*/ +if (WARN_ON (format_count >64 )) +return -EINVAL ; +WARN_ON (drm_drv_uses_atomic_modeset (dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state));
@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,return -ENOMEM ; } -/* -* First driver to need more than 64 formats needs to fix this. Each -* format is encoded as a bit and the current code only supports a u64. -*/ -if (WARN_ON (format_count >64 )) -return -EINVAL ; -if (format_modifiers) {const uint64_t *temp_modifiers = format_modifiers;
Signature · 1 line
2.25.1
Quoted 8 lines · Steven Price
While the check for
format_count> 64 in__drm_universal_plane_init()shouldn't be hit (it's aWARN_ON), in its current position it will then leak theplane->format_typesarray and fail to calldrm_mode_object_unregister()leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place.Signed-off-by Steven Price <[email protected]>
Well spotted!
I'm going to wait to see if anyone else has any comments before I'll merge this into drm-misc-fixes (or should it be drm-misc-next-fixes?)
Best regards,
Liviu
Quoted 39 lines
--- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_plane.c +7
-7@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,if (WARN_ON (config->num_total_plane >=32 ))return -EINVAL ; +/* +* First driver to need more than 64 formats needs to fix this. Each +* format is encoded as a bit and the current code only supports a u64. +*/ +if (WARN_ON (format_count >64 )) +return -EINVAL ; +WARN_ON (drm_drv_uses_atomic_modeset (dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state));@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,return -ENOMEM ; } -/* -* First driver to need more than 64 formats needs to fix this. Each -* format is encoded as a bit and the current code only supports a u64. -*/ -if (WARN_ON (format_count >64 )) -return -EINVAL ; -if (format_modifiers) {const uint64_t *temp_modifiers = format_modifiers;Signature · 1 line
2.25.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 8 lines · Liviu Dudau
Quoted 7 lines · Steven Price
While the check for
format_count> 64 in__drm_universal_plane_init()shouldn't be hit (it's aWARN_ON), in its current position it will then leak theplane->format_typesarray and fail to calldrm_mode_object_unregister()leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place.
Quoted 8 lines
Quoted 1 line
Signed-off-by Steven Price <[email protected]>Well spotted!
Reviewed-by Liviu Dudau <[email protected]>I'm going to wait to see if anyone else has any comments before I'll merge this into drm-misc-fixes (or should it be drm-misc-next-fixes?)
This definitely looks to fix an ugly I spotted too while looking at your prior patch thinking it might be wrong so a +1 from me.
Quoted 43 lines
Best regards,
LiviuQuoted 39 lines
--- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_plane.c +7
-7@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,if (WARN_ON (config->num_total_plane >=32 ))return -EINVAL ; +/* +* First driver to need more than 64 formats needs to fix this. Each +* format is encoded as a bit and the current code only supports a u64. +*/ +if (WARN_ON (format_count >64 )) +return -EINVAL ; +WARN_ON (drm_drv_uses_atomic_modeset (dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state));@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,return -ENOMEM ; } -/* -* First driver to need more than 64 formats needs to fix this. Each -* format is encoded as a bit and the current code only supports a u64. -*/ -if (WARN_ON (format_count >64 )) -return -EINVAL ; -if (format_modifiers) {const uint64_t *temp_modifiers = format_modifiers;Signature · 1 line
2.25.1
Quoted 8 lines · Liviu Dudau
Quoted 7 lines · Steven Price
While the check for
format_count> 64 in__drm_universal_plane_init()shouldn't be hit (it's aWARN_ON), in its current position it will then leak theplane->format_typesarray and fail to calldrm_mode_object_unregister()leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place.
Quoted 8 lines
Quoted 1 line
Signed-off-by Steven Price <[email protected]>Well spotted!
Reviewed-by Liviu Dudau <[email protected]>I'm going to wait to see if anyone else has any comments before I'll merge this into drm-misc-fixes (or should it be drm-misc-next-fixes?)
Gentle ping! I think we've probably waited long enough. Are you going to merge this or would you like me to?
Thanks,
Steve
Quoted 43 lines
Best regards,
LiviuQuoted 39 lines
--- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_plane.c +7
-7@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,if (WARN_ON (config->num_total_plane >=32 ))return -EINVAL ; +/* +* First driver to need more than 64 formats needs to fix this. Each +* format is encoded as a bit and the current code only supports a u64. +*/ +if (WARN_ON (format_count >64 )) +return -EINVAL ; +WARN_ON (drm_drv_uses_atomic_modeset (dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state));@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,return -ENOMEM ; } -/* -* First driver to need more than 64 formats needs to fix this. Each -* format is encoded as a bit and the current code only supports a u64. -*/ -if (WARN_ON (format_count >64 )) -return -EINVAL ; -if (format_modifiers) {const uint64_t *temp_modifiers = format_modifiers;Signature · 1 line
2.25.1
Quoted 13 lines · Steven Price
Quoted 12 lines · Liviu Dudau
Quoted 8 lines · Steven Price
While the check for
format_count> 64 in__drm_universal_plane_init()shouldn't be hit (it's aWARN_ON), in its current position it will then leak theplane->format_typesarray and fail to calldrm_mode_object_unregister()leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place.Signed-off-by Steven Price <[email protected]>Well spotted!
Quoted 7 lines
Quoted 4 lines
Reviewed-by Liviu Dudau <[email protected]>I'm going to wait to see if anyone else has any comments before I'll merge this into drm-misc-fixes (or should it be drm-misc-next-fixes?)
Gentle ping! I think we've probably waited long enough. Are you going to merge this or would you like me to?
Apologies for dropping this! I will push this one today.
Best regards,
Liviu
Quoted 49 lines
Thanks,
Steve
Quoted 43 lines
Best regards,
LiviuQuoted 39 lines
--- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_plane.c +7
-7@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,if (WARN_ON (config->num_total_plane >=32 ))return -EINVAL ; +/* +* First driver to need more than 64 formats needs to fix this. Each +* format is encoded as a bit and the current code only supports a u64. +*/ +if (WARN_ON (format_count >64 )) +return -EINVAL ; +WARN_ON (drm_drv_uses_atomic_modeset (dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state));@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,return -ENOMEM ; } -/* -* First driver to need more than 64 formats needs to fix this. Each -* format is encoded as a bit and the current code only supports a u64. -*/ -if (WARN_ON (format_count >64 )) -return -EINVAL ; -if (format_modifiers) {const uint64_t *temp_modifiers = format_modifiers;Signature · 1 line
2.25.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯