Received: by 10.223.164.221 with SMTP id h29csp3029630wrb; Thu, 2 Nov 2017 23:58:26 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TDcsma7X0EoxYuD/8XbyyVIWwj4pqwE+ZE+IgIMv3k99NG5dz3tDARGqYdywJLbDOD68q/ X-Received: by 10.159.206.193 with SMTP id x1mr5927717plo.319.1509692306358; Thu, 02 Nov 2017 23:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509692306; cv=none; d=google.com; s=arc-20160816; b=LJq38YnTatYHIqikmTsg4YhDvM9cXgt6bsq3zQlJXZUaJhMeEuGd21oNLEc8J3JGIT LR3eu4ZfgWZBJGkuebFm+JnZSNghPboEeNtqOVOyJw2ASSOnPm6Ww2lX4LXPpnQjZ+OY Bko3y8JAfxOzvM9ecKkDk2jfHC7m8xruicvCDmgAoD6RJRUZnkpZHC9u3AtffmVXuNzY gXbLLW2m32z7vFiz9V3MRq2ZsjSSU2OnoSkvN4GxCbmiZedCRFFtpQ2Z2G0o541oHLxM r3qBQ8el7DJ8bqUYjr6stQbRl+f6zOyvvx10XD5HGi0kUxfSRCXaoMp2LhN+zPmwDfAH rbGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=0X9U2+DqRhBvuz8dO/Uj7S9F53eRdvm4lIT8eH9oZE4=; b=E7fy+2LvX2tb4EbbtAQIf7LAkLDwF9lbdHsNEZHEdS2Fp0bIwTygSyVzP3X2c9Cvtt WwPoFnuA7x7zVFqBaXm8JU+LP19vjS8kD+Zr9Z9fCp5mL8BZGUjshGR3kRkmAVDEJk2y dGnih1Rdzcyv4HH9AvHkz9Uo79Ua0QleYtXAyDaoxQYk52hc3VHeHNsxi+xmhA+7lYA2 S0arYJjBzZMg/kD/HFFo1EIfno1AKmlgJrDRpLKl8wb58DtltFtZ0X/bWaEDeHTOKup/ 9sf/hTQnwrkEFmn7QVYbOED06Tix+G9wQC1QnMYP36Kx8DJPxWASw3kOVh1mQ+LzhQkg EQfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=DG5WogaJ; 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 g2si5140989pgr.506.2017.11.02.23.58.13; Thu, 02 Nov 2017 23:58:26 -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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=DG5WogaJ; 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 S1753486AbdKCG5g (ORCPT + 97 others); Fri, 3 Nov 2017 02:57:36 -0400 Received: from mail-by2nam03on0077.outbound.protection.outlook.com ([104.47.42.77]:21554 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750821AbdKCG5f (ORCPT ); Fri, 3 Nov 2017 02:57:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0X9U2+DqRhBvuz8dO/Uj7S9F53eRdvm4lIT8eH9oZE4=; b=DG5WogaJD3R+jywA9vakdq8U8Ybuovz9OwrDryYCjnw/d7sG9tlZZ2z73z4rFTorEUolVGwstnGPzaK2PzqRCuMdchFh2Q5eqngHtgRjWadvNwkumQM5+DWz4mzhF6hN2lW9EjGzob/GO2Hr6qJkDJTyorxlD+XtA5KDt+Vc6O4= Received: from BY2PR1201MB0935.namprd12.prod.outlook.com (10.164.167.19) by CY4PR12MB1302.namprd12.prod.outlook.com (10.168.168.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Fri, 3 Nov 2017 06:57:33 +0000 Received: from BY2PR1201MB0935.namprd12.prod.outlook.com ([10.164.167.19]) by BY2PR1201MB0935.namprd12.prod.outlook.com ([10.164.167.19]) with mapi id 15.20.0197.013; Fri, 3 Nov 2017 06:57:30 +0000 From: "Yu, Xiangliang" To: Arnd Bergmann , "Deucher, Alexander" , "Koenig, Christian" CC: David Airlie , "Liu, Monk" , "Chen, Horace" , "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module' struct Thread-Topic: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module' struct Thread-Index: AQHTU81rcOh+pKX3Q0iyfxjZRukzm6MCOjlw Date: Fri, 3 Nov 2017 06:57:30 +0000 Message-ID: References: <20171102112619.72157-1-arnd@arndb.de> In-Reply-To: <20171102112619.72157-1-arnd@arndb.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Xiangliang.Yu@amd.com; x-originating-ip: [116.228.147.243] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR12MB1302;20:Xcz2Pc4OUvyum0l9k+mP9tnMWf4SXJyRfoHanYLWyBkUoCYvzsvLYWKH1T702d+gB02O3Cjtfyr6RdFHwx0xMceQS0iqxet7zA7MkcXz1FY+RbDUtZRCWlryLMHYpMDayqgQjMVEqD5PVwoP8zNXxmbYp/sgJRcZCfQsVmB8rwMAJasihD7JlHCfDvDEXottxMG940tre3L28cDkQTiKDUGbQuyKllc58EQ6tRSjNWgpBnuHSPAaFjH019k0cVjt x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(6009001)(346002)(39860400002)(376002)(189002)(13464003)(199003)(53546010)(9686003)(55016002)(7696004)(72206003)(110136005)(54906003)(53936002)(478600001)(99286004)(6636002)(316002)(6246003)(74316002)(105586002)(5660300001)(106356001)(25786009)(4326008)(97736004)(305945005)(6506006)(229853002)(54356999)(76176999)(68736007)(8936002)(86362001)(81156014)(50986999)(7736002)(6116002)(3846002)(102836003)(3660700001)(189998001)(14454004)(2950100002)(2900100001)(8676002)(33656002)(77096006)(81166006)(66066001)(2906002)(6436002)(101416001)(3280700002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1302;H:BY2PR1201MB0935.namprd12.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 28412bb9-1b9f-4d74-c108-08d5228826c8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:CY4PR12MB1302; x-ms-traffictypediagnostic: CY4PR12MB1302: x-exchange-antispam-report-test: UriScan:(9452136761055)(767451399110)(217544274631240); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231021)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1302;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1302; x-forefront-prvs: 0480A51D4A received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28412bb9-1b9f-4d74-c108-08d5228826c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Nov 2017 06:57:30.2036 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1302 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-By: Xiangliang Yu Thanks! > -----Original Message----- > From: Arnd Bergmann [mailto:arnd@arndb.de] > Sent: Thursday, November 02, 2017 7:26 PM > To: Deucher, Alexander ; Koenig, Christian > > Cc: Arnd Bergmann ; David Airlie ; Liu, > Monk ; Yu, Xiangliang ; > Chen, Horace ; amd-gfx@lists.freedesktop.org; > dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org > Subject: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module' > struct >=20 > Accessing the THIS_MODULE directly is only possible when modules are > enabled, otherwise we get a build failure: >=20 > drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c: In function > 'amdgpu_virt_init_data_exchange': > drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:331:20: error: dereferencing > pointer to incomplete type 'struct module' >=20 > Further, THIS_MODULE is NULL when the driver is built-in, so the code wou= ld > likely cause a NULL pointer dereference. >=20 > This adds an #ifdef check to avoid the compile-time error, plus a NULL > pointer check before dereferencing THIS_MODULE. It might be better to fin= d > a way to avoid using the module version altogether. >=20 > Fixes: 2dc8f81e4f82 ("drm/amdgpu: SR-IOV data exchange between PF&VF") > Signed-off-by: Arnd Bergmann > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > index e97f80f86005..4e4a476593e8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > @@ -328,9 +328,11 @@ void amdgpu_virt_init_data_exchange(struct > amdgpu_device *adev) > sizeof(amdgim_vf2pf_info)); > AMDGPU_FW_VRAM_VF2PF_READ(adev, > driver_version, > &str); > +#ifdef MODULE > if (THIS_MODULE->version !=3D NULL) > strcpy(str, THIS_MODULE->version); > else > +#endif > strcpy(str, "N/A"); > AMDGPU_FW_VRAM_VF2PF_WRITE(adev, > driver_cert, > 0); > -- > 2.9.0 From 1582989971352067323@xxx Thu Nov 02 21:07:58 +0000 2017 X-GM-THRID: 1582953443006848179 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread