From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161047AbcHEIFA (ORCPT ); Fri, 5 Aug 2016 04:05:00 -0400 Received: from pegasos-out.vodafone.de ([80.84.1.38]:44635 "EHLO pegasos-out.vodafone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759458AbcHEIEg (ORCPT ); Fri, 5 Aug 2016 04:04:36 -0400 X-Spam-Flag: NO X-Spam-Score: -0.045 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 95BA65E2C62 Subject: Re: [PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm To: Amitoj Kaur Chawla , airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20160804154255.GA12191@amitoj-Inspiron-3542> Cc: julia.lawall@lip6.fr From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <743b4921-e44f-a1b4-a217-dd77a7a6ce2e@vodafone.de> Date: Fri, 5 Aug 2016 10:04:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160804154255.GA12191@amitoj-Inspiron-3542> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 04.08.2016 um 17:42 schrieb Amitoj Kaur Chawla: > To indicate an error, debugfs_create_file can return an ERR_PTR for > !CONFIG_DEBUG_FS and NULL otherwise, so in case the result is > dereferenced there should be a previous IS_ERR and a NULL check. > > The Coccinelle semantic patch used to find the issue is as follows: > @@ > expression e; > identifier f; > @@ > > * e = debugfs_create_file(...); > ... when != e == NULL > e->f > > Signed-off-by: Amitoj Kaur Chawla The whole section is surrounded by CONFIG_DEBUG_FS, so I suggest to just replace the check or IS_ERR with a NULL check. Regards, Christian. > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 8a1752f..9ff70a7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -1198,6 +1198,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) > adev, &amdgpu_ttm_vram_fops); > if (IS_ERR(ent)) > return PTR_ERR(ent); > + if (!ent) > + return -ENOMEM; > i_size_write(ent->d_inode, adev->mc.mc_vram_size); > adev->mman.vram = ent; > > @@ -1205,6 +1207,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) > adev, &amdgpu_ttm_gtt_fops); > if (IS_ERR(ent)) > return PTR_ERR(ent); > + if (!ent) > + return -ENOMEM; > i_size_write(ent->d_inode, adev->mc.gtt_size); > adev->mman.gtt = ent; >