From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Barnes Subject: Re: [PATCH 4/7] drm: plane: Check source coordinates Date: Fri, 11 Nov 2011 09:20:11 -0800 Message-ID: <20111111092011.08a3ce84@jbarnes-desktop> References: <1321027447-17921-1-git-send-email-ville.syrjala@linux.intel.com> <1321027447-17921-5-git-send-email-ville.syrjala@linux.intel.com> <20111111082418.5dd4c93a@jbarnes-desktop> <20111111171851.GE3477@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1939880483==" Return-path: Received: from oproxy5-pub.bluehost.com (oproxy5-pub.bluehost.com [67.222.38.55]) by gabe.freedesktop.org (Postfix) with SMTP id 5DAEFA0EEA for ; Fri, 11 Nov 2011 09:19:51 -0800 (PST) In-Reply-To: <20111111171851.GE3477@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Ville =?ISO-8859-1?B?U3lyauRs5A==?= Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1939880483== Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/j9YG87bO0pX+kZI8CEMgmte"; protocol="application/pgp-signature" --Sig_/j9YG87bO0pX+kZI8CEMgmte Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, 11 Nov 2011 19:18:52 +0200 Ville Syrj=E4l=E4 wrote: > On Fri, Nov 11, 2011 at 08:24:18AM -0800, Jesse Barnes wrote: > > On Fri, 11 Nov 2011 18:04:04 +0200 > > ville.syrjala@linux.intel.com wrote: > >=20 > > > From: Ville Syrj=E4l=E4 > > >=20 > > > Make sure the source coordinates stay within the buffer. > > >=20 > > > Signed-off-by: Ville Syrj=E4l=E4 > > > --- > > > drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ > > > 1 files changed, 23 insertions(+), 0 deletions(-) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > > > index 70f5747..098cc50 100644 > > > --- a/drivers/gpu/drm/drm_crtc.c > > > +++ b/drivers/gpu/drm/drm_crtc.c > > > @@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, v= oid *data, > > > struct drm_crtc *crtc; > > > struct drm_framebuffer *fb; > > > int ret =3D 0; > > > + unsigned int fb_width, fb_height; > > > =20 > > > if (!drm_core_check_feature(dev, DRIVER_MODESET)) > > > return -EINVAL; > > > @@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, = void *data, > > > } > > > fb =3D obj_to_fb(obj); > > > =20 > > > + fb_width =3D fb->width << 16; > > > + fb_height =3D fb->height << 16; > > > + > > > + /* Make sure source coordinates are inside the fb. */ > > > + if (plane_req->src_w > fb_width || > > > + plane_req->src_x > fb_width - plane_req->src_w || > > > + plane_req->src_h > fb_height || > > > + plane_req->src_y > fb_height - plane_req->src_h) { > > > + DRM_DEBUG_KMS("Invalid source coordinates " > > > + "%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n", > > > + plane_req->src_w >> 16, > > > + ((plane_req->src_w & 0xffff) * 15625) >> 10, > > > + plane_req->src_h >> 16, > > > + ((plane_req->src_h & 0xffff) * 15625) >> 10, > > > + plane_req->src_x >> 16, > > > + ((plane_req->src_x & 0xffff) * 15625) >> 10, > > > + plane_req->src_y >> 16, > > > + ((plane_req->src_y & 0xffff) * 15625) >> 10); > > > + ret =3D -EINVAL; > > > + goto out; > > > + } > > > + > > > ret =3D plane->funcs->update_plane(plane, crtc, fb, > > > plane_req->crtc_x, plane_req->crtc_y, > > > plane_req->crtc_w, plane_req->crtc_h, > >=20 > > Good sanity check (saves the drivers from having to do it), but I > > wonder if we can use a better return value like ENOSPC or something to > > make it easier for userspace to figure out. >=20 > Yeah, getting EINVAL for every kind of failure is rather annoying. The > only issue I have with ENOSPC is the strerror() output. It doesn't > exactly fit this use case. But if there's nothing better I'm OK with > ENOSPC. Yeah, dunno what's best. Check out include/asm-generic/errno-base.h and errno.h; maybe you'll find a better fit. --=20 Jesse Barnes, Intel Open Source Technology Center --Sig_/j9YG87bO0pX+kZI8CEMgmte Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJOvVlLAAoJEIEoDkX4Qk9h5ToP+QGuzdVYPEChvldnzWTDPuHw LS1ynvJbcfcWlKdWMLXrh05iKZ6FrdTQDj6ck62mKuC3/BC1V8UZa9xzN2cmm31K k/0Eg1x0nnaTf2rfpVhxktPN3zkvizcDKUktlG1locrY25GMa7hLtHtZfH+TweDj Sy8/bhtbzZJEHWDRPZcyuCNUkjDIu9xCLGVlXxcdrn80MjNzyaAm1cAPzMTUkp/s IW6WUmZPL1a5zXjsAN+F89L6QGghMEHNYxfYoQXSvvGKbFVtCEYI898zMUEgbRwu 2jxcRNpRSI2/fuUWGipNGuDEndUY3cHGiIYUmdCfxBwNuh4w4MWnkL9cqAnef+ye wc0sNYkAJVB78fGcutwDLaHYxKJ9zPS7b+V8DxJzMlR8hYJUhazESMM7CBaCoyUi ddpTGzzilQ9JOLTxLiQSBNAgKlp25wtQzi4D8C7FEDYYsF6IYM2fY1mDxdIphlEj aVkqn3CSeb4G/tfs8AnuKGPZQvjIM3F8U4DJe/O3+GMyzrtgtTnYfL54xIYnEerh BTpp92hxbCW352hHYBAiIf5E/HiFZDXVHzjsCJ6xhl2Trpr7oqCi9NoGHh3pUZsB kBJoTOygMSm1RqQION7u90q6a4BGp3CJBttdKBqjcCX7f8pVKnQjwnADpBfrbVG0 W8B6yz9M5/7tGp4gHvEr =+Md9 -----END PGP SIGNATURE----- --Sig_/j9YG87bO0pX+kZI8CEMgmte-- --===============1939880483== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1939880483==--