drm: Make sure that encoder_type for drm_encoder_init() is in the list
Subsystems (2)
PATCH 1/1 drm: Make sure that encoder_type for drm_encoder_init() is in the list
If a encoder name isn't specified for drm_encoder_init() it will try to construct one based on the incoming encoder_type identifier. If the caller passes an invalid encoder_type value the lookup could walk right past the end of the table.
[v2: Use a WARN() at the top of the function as suggested by Daniel
Vetter]
--- drivers/gpu/drm/drm_encoder.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_encoder.c +4 -0
@@ -114,6 +114,10 @@ int drm_encoder_init(struct drm_device *dev,if (WARN_ON (dev->mode_config.num_encoder >=32 ))return -EINVAL ; +/* Make sure that the requested encoder type is in the list */ +if (WARN_ON (encoder_type >=ARRAY_SIZE (drm_encoder_enum_list))) +return -EINVAL ; + ret =drm_mode_object_add (dev, &encoder->base,DRM_MODE_OBJECT_ENCODER );if (ret)return ret;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Jordan Crouse
If a encoder name isn't specified for
drm_encoder_init()it will try to construct one based on the incomingencoder_typeidentifier. If the caller passes an invalidencoder_typevalue the lookup could walk right past the end of the table.[v2: Use a
WARN()at the top of the function as suggested by Daniel
Vetter]Signed-off-by Jordan Crouse <[email protected]>
Aside: Want drm-misc commit rights so you can push patches like these yourself?
Might also be useful in case the group maintainership thing with msm happens, just as prep.
-Daniel
Quoted 22 lines
--- drivers/gpu/drm/drm_encoder.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/drm_encoder.c +4
-0@@ -114,6 +114,10 @@ int drm_encoder_init(struct drm_device *dev,if (WARN_ON (dev->mode_config.num_encoder >=32 ))return -EINVAL ; +/* Make sure that the requested encoder type is in the list */ +if (WARN_ON (encoder_type >=ARRAY_SIZE (drm_encoder_enum_list))) +return -EINVAL ; + ret =drm_mode_object_add (dev, &encoder->base,DRM_MODE_OBJECT_ENCODER );if (ret)return ret;Signature · 1 line
2.17.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel