Received: by 10.213.65.68 with SMTP id h4csp1837409imn; Mon, 19 Mar 2018 14:47:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELsM1qcGN7mW86wJS9FuLMVZJUNiMdAgTML+HGX7hUXKLzsPnexmtsY+Bq/Lb1bF5fsL197c X-Received: by 10.101.70.8 with SMTP id v8mr9798395pgq.336.1521496041734; Mon, 19 Mar 2018 14:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521496041; cv=none; d=google.com; s=arc-20160816; b=sRcFaMiOXelhmEc4Si+7UkJ5ZDqSTVDiSgkzRxBpY8sWnBPN7XLvb/Adkmb1XNBu4C TZTIJbm0EbYIFMJa77CgmUnQHO/evqDIBM4sY4B9hi7xNpJIA9Ct0jRVJalQFzdwl8ku cpN4m0LeCFog5oveXni8H/a2HqJPxKxyOvB8jbyD807TzdGwapGTKMvjufc5adyz9814 lfoP1rE+c0ZLJC0/+xonNqsLbMcgBalyR+k4ww44w7c6fTBEEZ/mHjYXCI3q6Q7IKGAZ mwlXdHriCLyzshwRspyclgIDcKNxg+GuxMW10ob5INj0s4k1Nd+Y0RAe4tHBkNomKjLC /bfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Lt3W4ptT9/c0HQRCcd9KRoNpo1ctp4wbMui1EiwbBws=; b=UUNnWMOaztvGj8pocekTIDQRBlqo4/EqtVl0ATO0dRhPPCtgnwb0EfXv0cHZSqYDBc 5IrFYA+UoMWl8CwF8J58J+dTjMV3NVfpFQMzrbqJbJH/1tFyAmrufMVwWwaivtTTIO3F tOU4Q1RhNfnfTwKsBCCpHau57ZTEnmbHw2neSYoyYYCDIMzGMdl3SPP6UZ286SRz8Ee4 K/sv4m9Rq9vVDsFDVu5xnBfOfgXCDRiHbG0yX0qri+LYY1HZf1HsHK7AUitiQ+rxAoC0 1K/SZBoskxycI2j32SfTZ71an5JsFzBE+zrV7t6WqQgTob2Sj5wKlMt8hQ1E7ydvSHj8 ChJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t61-v6si165984plb.195.2018.03.19.14.47.07; Mon, 19 Mar 2018 14:47:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971985AbeCSVpd (ORCPT + 99 others); Mon, 19 Mar 2018 17:45:33 -0400 Received: from gateway33.websitewelcome.com ([192.185.145.221]:40002 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964859AbeCSVp3 (ORCPT ); Mon, 19 Mar 2018 17:45:29 -0400 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 2574B25C0 for ; Mon, 19 Mar 2018 16:45:28 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id y2aueNEtOy2aLy2auepVI9; Mon, 19 Mar 2018 16:45:28 -0500 Received: from [189.145.36.34] (port=56610 helo=[192.168.1.67]) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ey2as-001RJz-Mh; Mon, 19 Mar 2018 16:45:26 -0500 Subject: Re: [PATCH] drm/i915/gvt/scheduler: fix potential NULL pointer dereference 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 References: <20180319193053.GA7016@embeddedgus> <152149190651.3594.5036347331521892974@mail.alporthouse.com> <8f70ff7b-9575-006b-2384-88899f24fda6@embeddedor.com> <152149459549.3594.15219721825785440264@mail.alporthouse.com> From: "Gustavo A. R. Silva" Message-ID: <276cc037-d768-1baa-aea5-da69c8d8a1e2@embeddedor.com> Date: Mon, 19 Mar 2018 16:45:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <152149459549.3594.15219721825785440264@mail.alporthouse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.145.36.34 X-Source-L: No X-Exim-ID: 1ey2as-001RJz-Mh X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.67]) [189.145.36.34]:56610 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 11 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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