All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
@ 2021-03-01  6:53 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-03-01  6:53 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3411 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Abhinav Kumar <abhinavk@codeaurora.org>
CC: Rob Clark <robdclark@chromium.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add debugfs support to DP driver
date:   6 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 6 months ago
config: arm64-randconfig-m031-20210301 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c

d11a93690df7e9 Abhinav Kumar 2020-09-12  208  
d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int dp_debug_init(struct dp_debug *dp_debug)
d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private *debug = container_of(dp_debug,
d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct dp_debug_private, dp_debug);
d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, *file;
d11a93690df7e9 Abhinav Kumar 2020-09-12  215  
d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir = debugfs_create_dir(DEBUG_NAME, NULL);
d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s] debugfs create dir failed, rc = %d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;
d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  223  
d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file = debugfs_create_file("dp_debug", 0444, dir,
d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, &dp_debug_fops);
d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if (IS_ERR_OR_NULL(file)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s] debugfs create file failed, rc=%d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  232  
d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }
d11a93690df7e9 Abhinav Kumar 2020-09-12  240  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33102 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
  2021-03-01  7:14 ` Dan Carpenter
@ 2021-03-04  0:27   ` abhinavk
  -1 siblings, 0 replies; 6+ messages in thread
From: abhinavk @ 2021-03-04  0:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kbuild, lkp, kbuild-all, linux-kernel, Rob Clark

Hi Dan

Thanks for reporting this, will submit a change to fix this.

Abhinav

On 2021-02-28 23:14, Dan Carpenter wrote:
> tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> master
> head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
> commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add
> debugfs support to DP driver
> config: arm64-randconfig-m031-20210301 (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> New smatch warnings:
> drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing
> zero to 'PTR_ERR'
> 
> Old smatch warnings:
> drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing
> zero to 'PTR_ERR'
> 
> vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c
> 
> d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int
> dp_debug_init(struct dp_debug *dp_debug)
> d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
> d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private
> *debug = container_of(dp_debug,
> d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct
> dp_debug_private, dp_debug);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, 
> *file;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  215
> d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir =
> debugfs_create_dir(DEBUG_NAME, NULL);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) 
> {
> d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s]
> debugfs create dir failed, rc = %d\n",
> d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;
> 
> Debugfs function never return NULL, but actually debugfs functions
> aren't supposed to be checked in the normal case (the abnormal case is
> where you are trying to dereference "dir" and "file" within the driver
> itself, so it doesn't apply here).
> 
> So then the function becomes a lot simpler, if it's written in the
> canonical way.  This should probably be documented better in the
> Documentation/filesystems/debugfs.rst file...  :/
> 
> static void dp_debug_init(struct dp_debug *dp_debug)
> {
> 	struct dp_debug_private *debug = container_of(dp_debug,
> 						      struct dp_debug_private, dp_debug);
> 
> 	debug->root = debugfs_create_dir(DEBUG_NAME, NULL);
> 	debugfs_create_file("dp_debug", 0444, dir, debug, &dp_debug_fops);
> }
> 
> d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
> d11a93690df7e9 Abhinav Kumar 2020-09-12  223
> d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file =
> debugfs_create_file("dp_debug", 0444, dir,
> d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, 
> &dp_debug_fops);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if 
> (IS_ERR_OR_NULL(file)) {
> d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s]
> debugfs create file failed, rc=%d\n",
> d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
> d11a93690df7e9 Abhinav Kumar 2020-09-12  232
> d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
> d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
> d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
@ 2021-03-04  0:27   ` abhinavk
  0 siblings, 0 replies; 6+ messages in thread
From: abhinavk @ 2021-03-04  0:27 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4119 bytes --]

Hi Dan

Thanks for reporting this, will submit a change to fix this.

Abhinav

On 2021-02-28 23:14, Dan Carpenter wrote:
> tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> master
> head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
> commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add
> debugfs support to DP driver
> config: arm64-randconfig-m031-20210301 (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> New smatch warnings:
> drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing
> zero to 'PTR_ERR'
> 
> Old smatch warnings:
> drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing
> zero to 'PTR_ERR'
> 
> vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c
> 
> d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int
> dp_debug_init(struct dp_debug *dp_debug)
> d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
> d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private
> *debug = container_of(dp_debug,
> d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct
> dp_debug_private, dp_debug);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, 
> *file;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  215
> d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir =
> debugfs_create_dir(DEBUG_NAME, NULL);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) 
> {
> d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s]
> debugfs create dir failed, rc = %d\n",
> d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;
> 
> Debugfs function never return NULL, but actually debugfs functions
> aren't supposed to be checked in the normal case (the abnormal case is
> where you are trying to dereference "dir" and "file" within the driver
> itself, so it doesn't apply here).
> 
> So then the function becomes a lot simpler, if it's written in the
> canonical way.  This should probably be documented better in the
> Documentation/filesystems/debugfs.rst file...  :/
> 
> static void dp_debug_init(struct dp_debug *dp_debug)
> {
> 	struct dp_debug_private *debug = container_of(dp_debug,
> 						      struct dp_debug_private, dp_debug);
> 
> 	debug->root = debugfs_create_dir(DEBUG_NAME, NULL);
> 	debugfs_create_file("dp_debug", 0444, dir, debug, &dp_debug_fops);
> }
> 
> d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
> d11a93690df7e9 Abhinav Kumar 2020-09-12  223
> d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file =
> debugfs_create_file("dp_debug", 0444, dir,
> d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, 
> &dp_debug_fops);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if 
> (IS_ERR_OR_NULL(file)) {
> d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s]
> debugfs create file failed, rc=%d\n",
> d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
> d11a93690df7e9 Abhinav Kumar 2020-09-12  232
> d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
> d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
> d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
> d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
> d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
@ 2021-03-01  7:14 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-03-01  7:14 UTC (permalink / raw)
  To: kbuild, Abhinav Kumar; +Cc: lkp, kbuild-all, linux-kernel, Rob Clark

[-- Attachment #1: Type: text/plain, Size: 3731 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add debugfs support to DP driver
config: arm64-randconfig-m031-20210301 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c

d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int dp_debug_init(struct dp_debug *dp_debug)
d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private *debug = container_of(dp_debug,
d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct dp_debug_private, dp_debug);
d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, *file;
d11a93690df7e9 Abhinav Kumar 2020-09-12  215  
d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir = debugfs_create_dir(DEBUG_NAME, NULL);
d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s] debugfs create dir failed, rc = %d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;

Debugfs function never return NULL, but actually debugfs functions
aren't supposed to be checked in the normal case (the abnormal case is
where you are trying to dereference "dir" and "file" within the driver
itself, so it doesn't apply here).

So then the function becomes a lot simpler, if it's written in the
canonical way.  This should probably be documented better in the
Documentation/filesystems/debugfs.rst file...  :/

static void dp_debug_init(struct dp_debug *dp_debug)
{
	struct dp_debug_private *debug = container_of(dp_debug,
						      struct dp_debug_private, dp_debug);

	debug->root = debugfs_create_dir(DEBUG_NAME, NULL);
	debugfs_create_file("dp_debug", 0444, dir, debug, &dp_debug_fops);
}

d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  223  
d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file = debugfs_create_file("dp_debug", 0444, dir,
d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, &dp_debug_fops);
d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if (IS_ERR_OR_NULL(file)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s] debugfs create file failed, rc=%d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  232  
d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33102 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
@ 2021-03-01  7:14 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-03-01  7:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3805 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add debugfs support to DP driver
config: arm64-randconfig-m031-20210301 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c

d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int dp_debug_init(struct dp_debug *dp_debug)
d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private *debug = container_of(dp_debug,
d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct dp_debug_private, dp_debug);
d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, *file;
d11a93690df7e9 Abhinav Kumar 2020-09-12  215  
d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir = debugfs_create_dir(DEBUG_NAME, NULL);
d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s] debugfs create dir failed, rc = %d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;

Debugfs function never return NULL, but actually debugfs functions
aren't supposed to be checked in the normal case (the abnormal case is
where you are trying to dereference "dir" and "file" within the driver
itself, so it doesn't apply here).

So then the function becomes a lot simpler, if it's written in the
canonical way.  This should probably be documented better in the
Documentation/filesystems/debugfs.rst file...  :/

static void dp_debug_init(struct dp_debug *dp_debug)
{
	struct dp_debug_private *debug = container_of(dp_debug,
						      struct dp_debug_private, dp_debug);

	debug->root = debugfs_create_dir(DEBUG_NAME, NULL);
	debugfs_create_file("dp_debug", 0444, dir, debug, &dp_debug_fops);
}

d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  223  
d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file = debugfs_create_file("dp_debug", 0444, dir,
d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, &dp_debug_fops);
d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if (IS_ERR_OR_NULL(file)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s] debugfs create file failed, rc=%d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  232  
d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33102 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'
@ 2021-03-01  7:14 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-03-01  7:14 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3805 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: d11a93690df7e9a7e07c0784ecad019a627b1449 drm/msm/dp: add debugfs support to DP driver
config: arm64-randconfig-m031-20210301 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/gpu/drm/msm/dp/dp_debug.c:227 dp_debug_init() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +218 drivers/gpu/drm/msm/dp/dp_debug.c

d11a93690df7e9 Abhinav Kumar 2020-09-12  209  static int dp_debug_init(struct dp_debug *dp_debug)
d11a93690df7e9 Abhinav Kumar 2020-09-12  210  {
d11a93690df7e9 Abhinav Kumar 2020-09-12  211  	int rc = 0;
d11a93690df7e9 Abhinav Kumar 2020-09-12  212  	struct dp_debug_private *debug = container_of(dp_debug,
d11a93690df7e9 Abhinav Kumar 2020-09-12  213  			struct dp_debug_private, dp_debug);
d11a93690df7e9 Abhinav Kumar 2020-09-12  214  	struct dentry *dir, *file;
d11a93690df7e9 Abhinav Kumar 2020-09-12  215  
d11a93690df7e9 Abhinav Kumar 2020-09-12  216  	dir = debugfs_create_dir(DEBUG_NAME, NULL);
d11a93690df7e9 Abhinav Kumar 2020-09-12  217  	if (IS_ERR_OR_NULL(dir)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12 @218  		rc = PTR_ERR(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  219  		DRM_ERROR("[%s] debugfs create dir failed, rc = %d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  220  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  221  		goto error;

Debugfs function never return NULL, but actually debugfs functions
aren't supposed to be checked in the normal case (the abnormal case is
where you are trying to dereference "dir" and "file" within the driver
itself, so it doesn't apply here).

So then the function becomes a lot simpler, if it's written in the
canonical way.  This should probably be documented better in the
Documentation/filesystems/debugfs.rst file...  :/

static void dp_debug_init(struct dp_debug *dp_debug)
{
	struct dp_debug_private *debug = container_of(dp_debug,
						      struct dp_debug_private, dp_debug);

	debug->root = debugfs_create_dir(DEBUG_NAME, NULL);
	debugfs_create_file("dp_debug", 0444, dir, debug, &dp_debug_fops);
}

d11a93690df7e9 Abhinav Kumar 2020-09-12  222  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  223  
d11a93690df7e9 Abhinav Kumar 2020-09-12  224  	file = debugfs_create_file("dp_debug", 0444, dir,
d11a93690df7e9 Abhinav Kumar 2020-09-12  225  			debug, &dp_debug_fops);
d11a93690df7e9 Abhinav Kumar 2020-09-12  226  	if (IS_ERR_OR_NULL(file)) {
d11a93690df7e9 Abhinav Kumar 2020-09-12  227  		rc = PTR_ERR(file);
d11a93690df7e9 Abhinav Kumar 2020-09-12  228  		DRM_ERROR("[%s] debugfs create file failed, rc=%d\n",
d11a93690df7e9 Abhinav Kumar 2020-09-12  229  				  DEBUG_NAME, rc);
d11a93690df7e9 Abhinav Kumar 2020-09-12  230  		goto error_remove_dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  231  	}
d11a93690df7e9 Abhinav Kumar 2020-09-12  232  
d11a93690df7e9 Abhinav Kumar 2020-09-12  233  	debug->root = dir;
d11a93690df7e9 Abhinav Kumar 2020-09-12  234  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  235   error_remove_dir:
d11a93690df7e9 Abhinav Kumar 2020-09-12  236  	debugfs_remove(dir);
d11a93690df7e9 Abhinav Kumar 2020-09-12  237   error:
d11a93690df7e9 Abhinav Kumar 2020-09-12  238  	return rc;
d11a93690df7e9 Abhinav Kumar 2020-09-12  239  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33102 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-04  1:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01  6:53 drivers/gpu/drm/msm/dp/dp_debug.c:218 dp_debug_init() warn: passing zero to 'PTR_ERR' kernel test robot
2021-03-01  7:14 Dan Carpenter
2021-03-01  7:14 ` Dan Carpenter
2021-03-01  7:14 ` Dan Carpenter
2021-03-04  0:27 ` abhinavk
2021-03-04  0:27   ` abhinavk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.