From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933237AbcHDPoy (ORCPT ); Thu, 4 Aug 2016 11:44:54 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33689 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757695AbcHDPow (ORCPT ); Thu, 4 Aug 2016 11:44:52 -0400 Date: Thu, 4 Aug 2016 21:14:41 +0530 From: Amitoj Kaur Chawla To: airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] drm/amdgpu: Modify error handling Message-ID: <20160804154441.GA12255@amitoj-Inspiron-3542> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 6553146..4c1a2bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2143,6 +2143,8 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) adev, &amdgpu_debugfs_regs_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->rmmio_size); adev->debugfs_regs = ent; -- 1.9.1