diff mbox series

[-next] platform/x86: intel-ips: fix 'passing zero to ERR_PTR()' warning

Message ID 20181126130646.22568-1-yuehaibing@huawei.com (mailing list archive)
State Rejected, archived
Headers show
Series [-next] platform/x86: intel-ips: fix 'passing zero to ERR_PTR()' warning | expand

Commit Message

Yue Haibing Nov. 26, 2018, 1:06 p.m. UTC
Fix a static code checker warning:
drivers/platform/x86/intel_ips.c:1314
 ips_debugfs_init() warn: passing zero to 'PTR_ERR'
drivers/platform/x86/intel_ips.c:1328
 ips_debugfs_init() warn: passing zero to 'PTR_ERR'

If error occurs,debugfs_create_dir/debugfs_create_file
return NULL while debugfs is enabled, which should not
passing to ERR_PTR.

Fixes: aa7ffc01d254 ("x86 platform driver: intelligent power sharing driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/platform/x86/intel_ips.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Yue Haibing Nov. 26, 2018, 1:17 p.m. UTC | #1
On 2018/11/26 21:06, YueHaibing wrote:
> Fix a static code checker warning:
> drivers/platform/x86/intel_ips.c:1314
>  ips_debugfs_init() warn: passing zero to 'PTR_ERR'
> drivers/platform/x86/intel_ips.c:1328
>  ips_debugfs_init() warn: passing zero to 'PTR_ERR'
> 
> If error occurs,debugfs_create_dir/debugfs_create_file
> return NULL while debugfs is enabled, which should not
> passing to ERR_PTR.

Sorry, a typo 'ERR_PTR' should be 'PTR_ERR', will send v2.

> 
> Fixes: aa7ffc01d254 ("x86 platform driver: intelligent power sharing driver")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/platform/x86/intel_ips.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
> index 225638a..a5d1a68 100644
> --- a/drivers/platform/x86/intel_ips.c
> +++ b/drivers/platform/x86/intel_ips.c
> @@ -1311,8 +1311,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
>  
>  	ips->debug_root = debugfs_create_dir("ips", NULL);
>  	if (!ips->debug_root) {
> -		dev_err(ips->dev, "failed to create debugfs entries: %ld\n",
> -			PTR_ERR(ips->debug_root));
> +		dev_err(ips->dev, "failed to create debugfs entries\n")
>  		return;
>  	}
>  
> @@ -1325,8 +1324,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
>  					  ips->debug_root, node,
>  					  &ips_debugfs_ops);
>  		if (!ent) {
> -			dev_err(ips->dev, "failed to create debug file: %ld\n",
> -				PTR_ERR(ent));
> +			dev_err(ips->dev, "failed to create debug file\n");
>  			goto err_cleanup;
>  		}
>  	}
>
kernel test robot Nov. 26, 2018, 1:38 p.m. UTC | #2
Hi YueHaibing,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20181126]

url:    https://github.com/0day-ci/linux/commits/YueHaibing/platform-x86-intel-ips-fix-passing-zero-to-ERR_PTR-warning/20181126-211845
config: x86_64-randconfig-x019-201847 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/platform/x86/intel_ips.c: In function 'ips_debugfs_init':
>> drivers/platform/x86/intel_ips.c:1315:3: error: expected ';' before 'return'
      return;
      ^~~~~~

vim +1315 drivers/platform/x86/intel_ips.c

aa7ffc01 Jesse Barnes 2010-05-14  1307  
aa7ffc01 Jesse Barnes 2010-05-14  1308  static void ips_debugfs_init(struct ips_driver *ips)
aa7ffc01 Jesse Barnes 2010-05-14  1309  {
aa7ffc01 Jesse Barnes 2010-05-14  1310  	int i;
aa7ffc01 Jesse Barnes 2010-05-14  1311  
aa7ffc01 Jesse Barnes 2010-05-14  1312  	ips->debug_root = debugfs_create_dir("ips", NULL);
aa7ffc01 Jesse Barnes 2010-05-14  1313  	if (!ips->debug_root) {
d18c8b17 YueHaibing   2018-11-26  1314  		dev_err(ips->dev, "failed to create debugfs entries\n")
aa7ffc01 Jesse Barnes 2010-05-14 @1315  		return;
aa7ffc01 Jesse Barnes 2010-05-14  1316  	}
aa7ffc01 Jesse Barnes 2010-05-14  1317  
aa7ffc01 Jesse Barnes 2010-05-14  1318  	for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) {
aa7ffc01 Jesse Barnes 2010-05-14  1319  		struct dentry *ent;
aa7ffc01 Jesse Barnes 2010-05-14  1320  		struct ips_debugfs_node *node = &ips_debug_files[i];
aa7ffc01 Jesse Barnes 2010-05-14  1321  
aa7ffc01 Jesse Barnes 2010-05-14  1322  		node->ips = ips;
aa7ffc01 Jesse Barnes 2010-05-14  1323  		ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO,
aa7ffc01 Jesse Barnes 2010-05-14  1324  					  ips->debug_root, node,
aa7ffc01 Jesse Barnes 2010-05-14  1325  					  &ips_debugfs_ops);
aa7ffc01 Jesse Barnes 2010-05-14  1326  		if (!ent) {
d18c8b17 YueHaibing   2018-11-26  1327  			dev_err(ips->dev, "failed to create debug file\n");
aa7ffc01 Jesse Barnes 2010-05-14  1328  			goto err_cleanup;
aa7ffc01 Jesse Barnes 2010-05-14  1329  		}
aa7ffc01 Jesse Barnes 2010-05-14  1330  	}
aa7ffc01 Jesse Barnes 2010-05-14  1331  
aa7ffc01 Jesse Barnes 2010-05-14  1332  	return;
aa7ffc01 Jesse Barnes 2010-05-14  1333  
aa7ffc01 Jesse Barnes 2010-05-14  1334  err_cleanup:
aa7ffc01 Jesse Barnes 2010-05-14  1335  	ips_debugfs_cleanup(ips);
aa7ffc01 Jesse Barnes 2010-05-14  1336  	return;
aa7ffc01 Jesse Barnes 2010-05-14  1337  }
aa7ffc01 Jesse Barnes 2010-05-14  1338  #endif /* CONFIG_DEBUG_FS */
aa7ffc01 Jesse Barnes 2010-05-14  1339  

:::::: The code at line 1315 was first introduced by commit
:::::: aa7ffc01d254c91a36bf854d57a14049c6134c72 x86 platform driver: intelligent power sharing driver

:::::: TO: Jesse Barnes <jbarnes@virtuousgeek.org>
:::::: CC: Matthew Garrett <mjg@redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 225638a..a5d1a68 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -1311,8 +1311,7 @@  static void ips_debugfs_init(struct ips_driver *ips)
 
 	ips->debug_root = debugfs_create_dir("ips", NULL);
 	if (!ips->debug_root) {
-		dev_err(ips->dev, "failed to create debugfs entries: %ld\n",
-			PTR_ERR(ips->debug_root));
+		dev_err(ips->dev, "failed to create debugfs entries\n")
 		return;
 	}
 
@@ -1325,8 +1324,7 @@  static void ips_debugfs_init(struct ips_driver *ips)
 					  ips->debug_root, node,
 					  &ips_debugfs_ops);
 		if (!ent) {
-			dev_err(ips->dev, "failed to create debug file: %ld\n",
-				PTR_ERR(ent));
+			dev_err(ips->dev, "failed to create debug file\n");
 			goto err_cleanup;
 		}
 	}