[Intel-gfx] [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Thu Mar 23 14:11:00 UTC 2017


Dropping the irrelevant Cc's.

On to, 2017-03-23 at 12:39 +0000, Chris Wilson wrote:
> On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> > 
> > From: Colin Ian King <colin.king at canonical.com>
> > 
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference.  If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
>
> It is never NULL, it gets checked by its only caller.

Took me a while to make any sense of the code as gvt_vgpu_err depends
on a vgpu variable being declared in the scope without taking it as a
parameter and that is a one big no-no:

https://01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html#macros-enums-and-rtl

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation


More information about the Intel-gfx mailing list