From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH] drm: check user mode flags for validity Date: Thu, 9 May 2013 01:25:59 +0300 Message-ID: <20130508222559.GP14974@intel.com> References: <20130508103940.GG14974@intel.com> <1368046886-11932-1-git-send-email-jbarnes@virtuousgeek.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id DD192E5C5F for ; Wed, 8 May 2013 15:26:02 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1368046886-11932-1-git-send-email-jbarnes@virtuousgeek.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Jesse Barnes Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, May 08, 2013 at 02:01:25PM -0700, Jesse Barnes wrote: > Requested-by: Ville Syrj=E4l=E4 > Signed-off-by: Jesse Barnes > --- > drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > = > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index 792c3e3..72ae33a 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -1318,6 +1318,18 @@ static int drm_crtc_convert_umode(struct drm_displ= ay_mode *out, > if (in->clock > INT_MAX || in->vrefresh > INT_MAX) > return -ERANGE; > = > + /* Reject modes with invalid h/vsync */ > + if (!(in->flags & (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC))) > + return -EINVAL; > + if ((in->flags & DRM_MODE_FLAG_PHSYNC) && > + (in->flags & DRM_MODE_FLAG_NHSYNC)) > + return -EINVAL; > + if (!(in->flags & (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC))) > + return -EINVAL; > + if ((in->flags & DRM_MODE_FLAG_PVSYNC) && > + (in->flags & DRM_MODE_FLAG_NVSYNC)) > + return -EINVAL; That might be a bit too drastic. Well I suppose making sure that both flags are not enabled at the same time could be OK. But having neither flag set could be perfectly legal (the user could be asking for composite sync instead for example). So my less drastic suggestion would be doing something like this in i915 specific code: adjusted_mode->flags =3D 0; if (requested_mode->flags & NHSYNC) adjusted_mode->flags |=3D NHSYNC; else adjusted_mode->flags |=3D PHSYNC; It would gurantee that we end up picking exactly one of the flags in every case. If both are set, we pick -, of neither is set we pick +. > + > out->clock =3D in->clock; > out->hdisplay =3D in->hdisplay; > out->hsync_start =3D in->hsync_start; > -- = > 1.7.9.5 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Ville Syrj=E4l=E4 Intel OTC