From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 4/8] drm: Allow drm_mode_object_find() to look up an object of any type Date: Thu, 29 May 2014 13:18:20 +0200 Message-ID: <20140529111820.GA19050@phenom.ffwll.local> References: <1401321445-31906-1-git-send-email-robdclark@gmail.com> <1401321445-31906-5-git-send-email-robdclark@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by gabe.freedesktop.org (Postfix) with ESMTP id BD85F6E32F for ; Thu, 29 May 2014 04:18:30 -0700 (PDT) Received: by mail-wi0-f178.google.com with SMTP id cc10so420813wib.5 for ; Thu, 29 May 2014 04:18:29 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1401321445-31906-5-git-send-email-robdclark@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Rob Clark Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Wed, May 28, 2014 at 07:57:21PM -0400, Rob Clark wrote: > From: Ville Syrj=E4l=E4 > = > To avoid having to pass object types from userspace for atomic mode > setting ioctl, allow drm_mode_object_find() to look up an object of any > type. This will only work as long as the all object types share the ID > space. > = > Signed-off-by: Ville Syrj=E4l=E4 > Signed-off-by: Rob Clark Still NACK. Iirc you only want a boolean "does this exist" so please add a new function for this. Returning a full pointer for framebuffer is simply unsafe, allowing that a call for trouble. Yes, I know your current code is safe but I don't want to freak out and do an ad-hoc audit every time I stumble over this again. -Daniel > --- > drivers/gpu/drm/drm_crtc.c | 3 ++- > include/drm/drm_crtc.h | 1 + > 2 files changed, 3 insertions(+), 1 deletion(-) > = > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index c53ddc3..b975575 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -409,7 +409,8 @@ struct drm_mode_object *drm_mode_object_find(struct d= rm_device *dev, > = > mutex_lock(&dev->mode_config.idr_mutex); > obj =3D idr_find(&dev->mode_config.crtc_idr, id); > - if (!obj || (obj->type !=3D type) || (obj->id !=3D id)) > + if (!obj || (type !=3D DRM_MODE_OBJECT_ANY && obj->type !=3D type) || > + (obj->id !=3D id)) > obj =3D NULL; > mutex_unlock(&dev->mode_config.idr_mutex); > = > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h > index dbd7954..44d7964 100644 > --- a/include/drm/drm_crtc.h > +++ b/include/drm/drm_crtc.h > @@ -50,6 +50,7 @@ struct drm_clip_rect; > #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb > #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee > #define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd > +#define DRM_MODE_OBJECT_ANY 0 > = > struct drm_mode_object { > uint32_t id; > -- = > 1.9.3 > = -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch