public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>, Ben Widawsky <ben@bwidawsk.net>
Cc: Intel GFX <intel-gfx@lists.freedesktop.org>,
	Ben Widawsky <benjamin.widawsky@intel.com>
Subject: Re: [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl
Date: Fri, 20 Dec 2013 16:37:34 +0200	[thread overview]
Message-ID: <871u17k2q9.fsf@intel.com> (raw)
In-Reply-To: <20131220141044.GA23400@phenom.ffwll.local>

On Fri, 20 Dec 2013, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Dec 19, 2013 at 10:55:56PM -0800, Ben Widawsky wrote:
>> On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote:
>> > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky
>> > <benjamin.widawsky@intel.com> wrote:
>> > >         ctx = i915_gem_context_get(file->driver_priv, args->ctx_id);
>> > > -       if (IS_ERR(ctx)) {
>> > > +       if (IS_ERR_OR_NULL(ctx)) {
>> > 
>> > We now have half the callers check for IS_ERR and the others not.
>> > Afaics i915_gem_context_get can only return NULL or a real context
>> > though. Also from a quite read the expected error for a lookup failure
>> > is ENOENT (and there seems to be a testcase for this).
>> > -Daniel
>> 
>> 
>> To your first point:
>> I think checking null is always the right thing currently, but for
>> future proofing, IS_ERR_OR_NULL is really the right thing. After his
>> patch, I believe only i915_gem_context_destroy_ioctl is still incorrect.
>
> Using IS_ERR_OR_NULL on a return value which can never contain an
> encoded errno value is imo confusing, more so when it's inconsitently
> applied.

Moreover, the error path then goes on to return 0 for success when the
pointer is NULL.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2013-12-20 14:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 23:22 [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl Ben Widawsky
2013-12-20  6:05 ` Daniel Vetter
2013-12-20  6:55   ` Ben Widawsky
2013-12-20 14:11     ` Daniel Vetter
2013-12-20 14:37       ` Jani Nikula [this message]
2013-12-20 18:21         ` Ben Widawsky
2013-12-20 18:21       ` Ben Widawsky
2013-12-22 20:55 ` [PATCH] drm/i915/ppgtt: Never return a NULL context Ben Widawsky
2014-01-01  5:46   ` [PATCH] [v2] " Ben Widawsky
2014-01-02 14:34     ` Mika Kuoppala

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=871u17k2q9.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=ben@bwidawsk.net \
    --cc=benjamin.widawsky@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /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