From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>,
Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Subject: Re: [PATCH RESEND] drm: fix crash in drm_minor_alloc_release
Date: Mon, 7 Nov 2022 17:56:36 +0200 [thread overview]
Message-ID: <Y2kqtJH2K7O8sTu+@intel.com> (raw)
In-Reply-To: <20221107154041.GA3600973@linux.intel.com>
On Mon, Nov 07, 2022 at 04:40:41PM +0100, Stanislaw Gruszka wrote:
> On Mon, Nov 07, 2022 at 05:10:48PM +0200, Ville Syrjälä wrote:
> > On Mon, Nov 07, 2022 at 03:45:00PM +0100, Stanislaw Gruszka wrote:
> > > index 8214a0b1ab7f..e3a1243dd2ae 100644
> > > --- a/drivers/gpu/drm/drm_drv.c
> > > +++ b/drivers/gpu/drm/drm_drv.c
> > > @@ -102,7 +102,8 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
> > >
> > > WARN_ON(dev != minor->dev);
> > >
> > > - put_device(minor->kdev);
> > > + if (!IS_ERR(minor->kdev))
> > > + put_device(minor->kdev);
> >
> > Assigning error pointers into things is a terrible idea.
> > IMO the correct fix would be to not return some
> > half-constructed garbage from drm_minor_alloc().
> > So basically should at least partically revert
> > commit f96306f9892b ("drm: manage drm_minor cleanup with drmm_")
>
> I would prefer to not change any ordering or remove drmm_* stuff, since
> as pointed to above commit message, things are tricky there.
Looks to me that it's only tricky because of drmm. Without that it was
totally clear what was happening. I think if the managed stuff is making
stuff more tricky then it has failed its purpose.
>
> I think assigning NULL to minor->kdev should be fine:
>
> if (IS_ERR(minor->kdev)) {
> r = PTR_ERR(minor->kdev);
> minor->kdev = NULL;
> return r;
> }
>
> put_device() in drm_minor_alloc_release() will cope nicely with it.
>
> Regards
> Stanislaw
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2022-11-07 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 14:45 [PATCH RESEND] drm: fix crash in drm_minor_alloc_release Stanislaw Gruszka
2022-11-07 15:10 ` Ville Syrjälä
2022-11-07 15:40 ` Stanislaw Gruszka
2022-11-07 15:56 ` Ville Syrjälä [this message]
2022-11-08 16:24 ` Stanislaw Gruszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2kqtJH2K7O8sTu+@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=stanislaw.gruszka@linux.intel.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).