From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH 06/13] drm: add minor-lookup/release helpers Date: Fri, 21 Feb 2014 08:09:11 +0100 Message-ID: <20140221070910.GB22574@ulmo.nvidia.com> References: <1391004120-687-1-git-send-email-dh.herrmann@gmail.com> <1391004120-687-7-git-send-email-dh.herrmann@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0904262587==" Return-path: Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E971FB247 for ; Thu, 20 Feb 2014 23:09:15 -0800 (PST) Received: by mail-bk0-f51.google.com with SMTP id w10so928307bkz.38 for ; Thu, 20 Feb 2014 23:09:13 -0800 (PST) In-Reply-To: <1391004120-687-7-git-send-email-dh.herrmann@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: David Herrmann Cc: Daniel Vetter , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0904262587== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ftEhullJWpWg/VHq" Content-Disposition: inline --ftEhullJWpWg/VHq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 29, 2014 at 03:01:53PM +0100, David Herrmann wrote: [...] > diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c > index c51333e..d3232b6 100644 > --- a/drivers/gpu/drm/drm_stub.c > +++ b/drivers/gpu/drm/drm_stub.c > @@ -356,6 +356,45 @@ static void drm_unplug_minor(struct drm_minor *minor) > } > =20 > /** > + * drm_minor_acquire - Acquire a DRM minor > + * @minor_id: Minor ID of the DRM-minor > + * > + * Looks up the given minor-ID and returns the respective DRM-minor obje= ct. The > + * refence-count of the underlying device is increased so you must relea= se this > + * object with drm_minor_release(). > + * > + * As long as you hold this minor, it is guaranteed that the object and = the > + * minor->dev pointer will stay valid! However, the device may get unplu= gged and > + * unregistered while you hold the minor. > + * > + * Returns: > + * Pointer to minor-object with increased device-refcount, or PTR_ERR on > + * failure. > + */ > +struct drm_minor *drm_minor_acquire(unsigned int minor_id) > +{ > + struct drm_minor *minor; > + > + minor =3D idr_find(&drm_minors_idr, minor_id); > + if (!minor) > + return ERR_PTR(-ENODEV); > + > + drm_dev_ref(minor->dev); Is it possible that somebody would drop the last reference on the device right between the idr_find() call and drm_dev_ref()? In which case both the device and the minor will have become invalid when drm_dev_ref() is called. Thierry --ftEhullJWpWg/VHq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJTBvuWAAoJEN0jrNd/PrOhaf0QAMLrio277eX/Q/JPnmvtVrjm 2adFCaT/o5r/0jEivetcVwkpC8ro9gYYAB7PmIGOUjnX7eFAasioyO1ZHidMA8RK AB+kK7joKuf/iBWLD9/OqSWDasEaxIm1RNVWgrBEx72/+PSK0J5E8DL+pAdS0csr 11B/Ae/p4/oHzF4oPW71p/TyMGx5P3cPOaDlMNLEu7sjWpMwT+Jt3h07YY+phf8K 6K44xk6EL25qL602Z5M2ZoejMURCLrtsO4K7jIRT31a8QVp5Sf9xiT+VCw9d2cDi TiwLD/DqIDszN/3owAnlQYmhHUFqYCf8mk9BFKcZuRZ5jSQ4JcMqMRWu3GjAlfpq OpB8K7L9DVlIFnFv05GOQf1UZF1NzSrb1HR1KrcHB+9wt6KGjXtJ6vU2RXXcUB58 0Y/IP644+hH4aHlWxgX0Sl/gRo24dYYNOHZquJ1izhyOt+UMi6hyDEJqkOjv0ZdE ms1/ZyFleYc7wkz1db569v0VCacaVEwokoAfUMs5saRYaBPjfw2s1gcBSYLvP1tk 5X2WcVDQpVQuDDyHulQhzWwVfWiLLLlymMwtGRYNRe6swLyv9r/V7WGStUIE+uZH 2evkqrssOa4Q8n8IJwUflE1Id2n8jg6Nxjadqq1ijCcqCGJhLKo7BI+rH5anrkwg RYRcxMbv8BAok/rNC9Y7 =eQUh -----END PGP SIGNATURE----- --ftEhullJWpWg/VHq-- --===============0904262587== 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 --===============0904262587==--