[PATCH] drm/atomic-helper: Validate pointer before dereference

Sam Ravnborg sam at ravnborg.org
Mon Mar 11 21:47:08 UTC 2019


Hi Rodrigo


On Mon, Mar 11, 2019 at 06:01:20PM -0300, Rodrigo Siqueira wrote:
> The function disable_outputs() and
> drm_atomic_helper_commit_modeset_enables() tries to retrieve
> helper_private from the target CRTC, for dereferencing some operations.
> However, the current implementation does not check whether
> helper_private is null and, if not, if it has a valid pointer to a dpms
> and commit functions. This commit adds pointer validations before
> trying to dereference the dpms and commit function.
> 
> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 30 ++++++++++++++++-------------
>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> @@ -1277,11 +1279,13 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
>  		if (new_crtc_state->enable) {
>  			DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n",
>  					 crtc->base.id, crtc->name);
This DEBUG_ print is only relevant if the code actually
do something in the following.
So it seems more correct to fix the upper if () to:

>               if (new_crtc_state->enable && funcs != NULL) {
>  			DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n",
			...

The you also loose one indent and the calls are nicer.

(If used "funcs != NULL", but this is a matter of taste).

	Sam


More information about the dri-devel mailing list