[Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

Jani Nikula jani.nikula at linux.intel.com
Fri Dec 20 15:37:34 CET 2013


On Fri, 20 Dec 2013, Daniel Vetter <daniel at 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 at 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



More information about the Intel-gfx mailing list