diff mbox series

media: aspeed: Fix return value check in aspeed_video_debugfs_create()

Message ID 20221125092415.29635-1-zhengyongjun3@huawei.com
State New
Headers show
Series media: aspeed: Fix return value check in aspeed_video_debugfs_create() | expand

Commit Message

Zheng Yongjun Nov. 25, 2022, 9:24 a.m. UTC
In case of error, the function debugfs_create_file() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Fixes: 52fed10ad756 ("media: aspeed: add debugfs")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 drivers/media/platform/aspeed/aspeed-video.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.17.1

Comments

kernel test robot Nov. 25, 2022, 12:43 p.m. UTC | #1
Hi Zheng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on linus/master sailus-media-tree/streams v6.1-rc6]
[cannot apply to next-20221125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Zheng-Yongjun/media-aspeed-Fix-return-value-check-in-aspeed_video_debugfs_create/20221125-173242
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20221125092415.29635-1-zhengyongjun3%40huawei.com
patch subject: [PATCH] media: aspeed: Fix return value check in aspeed_video_debugfs_create()
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/6ef6de2d58d68d417a12877da05936440470b22e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Zheng-Yongjun/media-aspeed-Fix-return-value-check-in-aspeed_video_debugfs_create/20221125-173242
        git checkout 6ef6de2d58d68d417a12877da05936440470b22e
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/media/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/media/platform/aspeed/aspeed-video.c: In function 'aspeed_video_debugfs_create':
>> drivers/media/platform/aspeed/aspeed-video.c:1785:32: warning: passing argument 1 of 'ERR_PTR' makes integer from pointer without a cast [-Wint-conversion]
    1785 |                 return ERR_PTR(debugfs_entry);
         |                                ^~~~~~~~~~~~~
         |                                |
         |                                struct dentry *
   In file included from include/linux/container_of.h:6,
                    from include/linux/list.h:5,
                    from include/linux/preempt.h:11,
                    from arch/m68k/include/asm/irqflags.h:6,
                    from include/linux/irqflags.h:16,
                    from arch/m68k/include/asm/atomic.h:6,
                    from include/linux/atomic.h:7,
                    from drivers/media/platform/aspeed/aspeed-video.c:5:
   include/linux/err.h:24:48: note: expected 'long int' but argument is of type 'struct dentry *'
      24 | static inline void * __must_check ERR_PTR(long error)
         |                                           ~~~~~^~~~~
>> drivers/media/platform/aspeed/aspeed-video.c:1785:24: warning: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
    1785 |                 return ERR_PTR(debugfs_entry);
         |                        ^~~~~~~~~~~~~~~~~~~~~~


vim +/ERR_PTR +1785 drivers/media/platform/aspeed/aspeed-video.c

  1777	
  1778	static int aspeed_video_debugfs_create(struct aspeed_video *video)
  1779	{
  1780		debugfs_entry = debugfs_create_file(DEVICE_NAME, 0444, NULL,
  1781						    video,
  1782						    &aspeed_video_debugfs_ops);
  1783		if (IS_ERR(debugfs_entry)) {
  1784			aspeed_video_debugfs_remove(video);
> 1785			return ERR_PTR(debugfs_entry);
  1786		}
  1787	
  1788		return 0;
  1789	}
  1790	#else
  1791	static void aspeed_video_debugfs_remove(struct aspeed_video *video) { }
  1792	static int aspeed_video_debugfs_create(struct aspeed_video *video)
  1793	{
  1794		return 0;
  1795	}
  1796	#endif /* CONFIG_DEBUG_FS */
  1797
diff mbox series

Patch

diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c
index 20f795ccc11b..c8fc2450e409 100644
--- a/drivers/media/platform/aspeed/aspeed-video.c
+++ b/drivers/media/platform/aspeed/aspeed-video.c
@@ -1780,10 +1780,12 @@  static int aspeed_video_debugfs_create(struct aspeed_video *video)
 	debugfs_entry = debugfs_create_file(DEVICE_NAME, 0444, NULL,
 					    video,
 					    &aspeed_video_debugfs_ops);
-	if (!debugfs_entry)
+	if (IS_ERR(debugfs_entry)) {
 		aspeed_video_debugfs_remove(video);
+		return ERR_PTR(debugfs_entry);
+	}

-	return !debugfs_entry ? -EIO : 0;
+	return 0;
 }
 #else
 static void aspeed_video_debugfs_remove(struct aspeed_video *video) { }