Skip to contentSkip to conversation

drivers/clk/clk: check return value of clk_pm_runtime_get()

PATCH Superseded Li Zhong 2 participants 5 messages Aug 28, 2022 – Aug 29, 2022 Common clk

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 drivers/clk/clk: check return value of clk_pm_runtime_get()

From: lily <[email protected]>

clk_pm_runtime_get() could fail. Check the return status.

---
 drivers/clk/clk.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/clk/clk.c +5 -2
index 7fc191c15507..f22b86dfe2f2 100644
@@ -2981,8 +2981,11 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
 				     int level)
 {
 	struct clk_core *child;
-
-	clk_pm_runtime_get(c);
+	int ret;
+	
+	ret = clk_pm_runtime_get(c);
+    if (ret)
+        return;
 	clk_summary_show_one(s, c, level);
 	clk_pm_runtime_put(c);
 
Signature · 1 line
2.25.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.0-rc2 next-20220826] [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/Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: riscv-randconfig-r042-20220828 (https://download.01.org/0day-ci/archive/20220829/[email protected]/config)
compiler: riscv64-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/26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043 git checkout 26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
# 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=riscv SHELL=/bin/bash drivers/clk/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

drivers/clk/clk.c: In function 'clk_summary_show_subtree':

>> drivers/clk/clk.c:3014:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    3014 |     if (ret)
         |     ^~
   drivers/clk/clk.c:3016:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    3016 |         clk_summary_show_one(s, c, level);
         |         ^~~~~~~~~~~~~~~~~~~~

vim +/if +3014 drivers/clk/clk.c

3006
3007 static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
3008 int level)
3009 {
3010 struct clk_core *child;
3011 int ret;
3012
3013 ret = clk_pm_runtime_get(c);

> 3014	    if (ret)

3015 return;
3016 clk_summary_show_one(s, c, level);
3017 clk_pm_runtime_put(c);
3018
3019 hlist_for_each_entry(child, &c->children, child_node)
3020 clk_summary_show_subtree(s, child, level + 1);
3021 }
3022

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#2 lore raw
In reply to Li Zhong
Thank you for the patch! Perhaps something to improve:

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.0-rc3 next-20220826] [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/Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm-randconfig-r034-20220829 (https://download.01.org/0day-ci/archive/20220829/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project a2100daf12fb980a29fd1a9c85ccf8eaaaf79730)

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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043 git checkout 26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/clk/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

>> drivers/clk/clk.c:3016:2: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
           clk_summary_show_one(s, c, level);
           ^
   drivers/clk/clk.c:3014:5: note: previous statement is here
       if (ret)
       ^

1 warning generated.

vim +/if +3016 drivers/clk/clk.c

89ac8d7ae1cde0 Mike Turquette 2013-08-21  3006  
4dff95dc9477a3 Stephen Boyd   2015-04-30  3007  static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
4dff95dc9477a3 Stephen Boyd   2015-04-30  3008  				     int level)
4dff95dc9477a3 Stephen Boyd   2015-04-30  3009  {
4dff95dc9477a3 Stephen Boyd   2015-04-30  3010  	struct clk_core *child;
26ebbe49c7b40c lily           2022-08-28  3011  	int ret;
b2476490ef1113 Mike Turquette 2012-03-15  3012  	
26ebbe49c7b40c lily           2022-08-28  3013  	ret = clk_pm_runtime_get(c);
26ebbe49c7b40c lily           2022-08-28  3014      if (ret)
26ebbe49c7b40c lily           2022-08-28  3015          return;
4dff95dc9477a3 Stephen Boyd   2015-04-30 @3016  	clk_summary_show_one(s, c, level);
1bb294a7981c73 Taniya Das     2021-12-20  3017  	clk_pm_runtime_put(c);
0e1c03017549a9 Viresh Kumar   2012-04-11  3018  
4dff95dc9477a3 Stephen Boyd   2015-04-30  3019  	hlist_for_each_entry(child, &c->children, child_node)
4dff95dc9477a3 Stephen Boyd   2015-04-30  3020  		clk_summary_show_subtree(s, child, level + 1);

b2476490ef1113 Mike Turquette 2012-03-15 3021 }
b2476490ef1113 Mike Turquette 2012-03-15 3022

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#3 lore raw
In reply to Li Zhong
Thank you for the patch! Perhaps something to improve:

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.0-rc2 next-20220826] [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/Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arc-randconfig-r043-20220829 (https://download.01.org/0day-ci/archive/20220829/[email protected]/config)
compiler: arceb-elf-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/26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043 git checkout 26ebbe49c7b40cb8465ed2bba4e4e62c3a55bb93
# 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=arc SHELL=/bin/bash drivers/clk/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

In file included from include/linux/err.h:5,
from include/linux/clk.h:12, from drivers/clk/clk.c:9:
drivers/clk/clk.c: In function 'clk_summary_show_subtree':

>> include/linux/compiler.h:56:23: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
         |                       ^~
   drivers/clk/clk.c:3014:5: note: in expansion of macro 'if'
    3014 |     if (ret)
         |     ^~
   drivers/clk/clk.c:3016:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    3016 |         clk_summary_show_one(s, c, level);
         |         ^~~~~~~~~~~~~~~~~~~~

vim +/if +56 include/linux/compiler.h

2bcd521a684cc9 Steven Rostedt 2008-11-21  50  
2bcd521a684cc9 Steven Rostedt 2008-11-21  51  #ifdef CONFIG_PROFILE_ALL_BRANCHES
2bcd521a684cc9 Steven Rostedt 2008-11-21  52  /*
2bcd521a684cc9 Steven Rostedt 2008-11-21  53   * "Define 'is'", Bill Clinton
2bcd521a684cc9 Steven Rostedt 2008-11-21  54   * "Define 'if'", Steven Rostedt
2bcd521a684cc9 Steven Rostedt 2008-11-21  55   */

a15fd609ad53a6 Linus Torvalds 2019-03-20 @56 #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) a15fd609ad53a6 Linus Torvalds 2019-03-20 57

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#4 lore raw
In reply to Li Zhong
Thank you for the patch! Perhaps something to improve:

Hi Li,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.0-rc3 next-20220826] [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/Li-Zhong/drivers-clk-clk-check-return-value-of-clk_pm_runtime_get/20220829-042043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220829/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0

If you fix the issue, kindly add following tag where applicable

New smatch warnings:
drivers/clk/clk.c:3014 clk_summary_show_subtree() warn: inconsistent indenting drivers/clk/clk.c:3016 clk_summary_show_subtree() warn: curly braces intended?

Old smatch warnings:
drivers/clk/clk.c:3802 clk_hw_create_clk() warn: passing zero to 'ERR_CAST'

vim +3014 drivers/clk/clk.c

3006
3007 static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
3008 int level)
3009 {
3010 struct clk_core *child;
3011 int ret;
3012
3013 ret = clk_pm_runtime_get(c);

> 3014	    if (ret)
  3015	        return;
> 3016		clk_summary_show_one(s, c, level);

3017 clk_pm_runtime_put(c);
3018
3019 hlist_for_each_entry(child, &c->children, child_node)
3020 clk_summary_show_subtree(s, child, level + 1);
3021 }
3022

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp