From: "Gustavo A. R. Silva" Subject: Re: [PATCH] drm/i915/gvt/scheduler: fix potential NULL pointer dereference Date: Mon, 19 Mar 2018 16:45:24 -0500 Message-ID: <276cc037-d768-1baa-aea5-da69c8d8a1e2@embeddedor.com> References: <20180319193053.GA7016@embeddedgus> <152149190651.3594.5036347331521892974@mail.alporthouse.com> <8f70ff7b-9575-006b-2384-88899f24fda6@embeddedor.com> <152149459549.3594.15219721825785440264@mail.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <152149459549.3594.15219721825785440264@mail.alporthouse.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Chris Wilson , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie Cc: intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org On 03/19/2018 04:23 PM, Chris Wilson wrote: > Quoting Gustavo A. R. Silva (2018-03-19 20:50:12) >> Hi Chris, >> >> On 03/19/2018 03:38 PM, Chris Wilson wrote: >>> Quoting Gustavo A. R. Silva (2018-03-19 19:30:53) >>>> _workload_ is being dereferenced before it is null checked, hence >>>> there is a potential null pointer dereference. >>>> >>>> Fix this by moving the pointer dereference after _workload_ has >>>> been null checked. >>> >>> The checks are misleading and not required. >> >> All of them? >> >> if (!workload || !reg_state || workload->ring_id != RCS) >> return; > > workload can not be NULL (dereference in caller), reg_state can not be > NULL (by construct from kmap()). > > It may be not an RCS ring through I got it. I'll send the following patch then: --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c @@ -74,7 +74,7 @@ static void sr_oa_regs(struct intel_vgpu_workload *workload, i915_mmio_reg_offset(EU_PERF_CNTL6), }; - if (!workload || !reg_state || workload->ring_id != RCS) + if(workload->ring_id != RCS) return; if (save) { Thanks -- Gustavo