All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers/clk/keystone: avoid a memory leak
@ 2022-07-22  4:13 Yuanjun Gong
  2022-07-23  1:53 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yuanjun Gong @ 2022-07-22  4:13 UTC (permalink / raw)
  To: Yuanjun Gong, Santosh Shilimkar, linux-kernel

In ti_syscon_gate_clk_register, priv is allocated by devm_kzalloc.
On the error path, it should be freed before return.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/clk/keystone/syscon-clk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/keystone/syscon-clk.c b/drivers/clk/keystone/syscon-clk.c
index 19198325b909..d8919bdafe34 100644
--- a/drivers/clk/keystone/syscon-clk.c
+++ b/drivers/clk/keystone/syscon-clk.c
@@ -84,6 +84,7 @@ static struct clk_hw
 
 	ret = devm_clk_hw_register(dev, &priv->hw);
 	if (ret)
+		devm_kfree(dev, priv);
 		return ERR_PTR(ret);
 
 	return &priv->hw;
-- 
2.17.1


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

* Re: [PATCH 1/1] drivers/clk/keystone: avoid a memory leak
  2022-07-22  4:13 [PATCH 1/1] drivers/clk/keystone: avoid a memory leak Yuanjun Gong
@ 2022-07-23  1:53 ` kernel test robot
  2022-07-24  3:26 ` kernel test robot
  2022-07-24 15:08 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-07-23  1:53 UTC (permalink / raw)
  To: Yuanjun Gong, Santosh Shilimkar, linux-kernel; +Cc: llvm, kbuild-all

Hi Yuanjun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v5.19-rc7 next-20220722]
[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/Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220723/202207230958.CDbs3UDB-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 72686d68c137551cce816416190a18d45b4d4e2a)
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/c8db4a192822cdb1e77a32238a893d7a81081f80
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
        git checkout c8db4a192822cdb1e77a32238a893d7a81081f80
        # 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/keystone/

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/clk/keystone/syscon-clk.c:88:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
                   return ERR_PTR(ret);
                   ^
   drivers/clk/keystone/syscon-clk.c:86:2: note: previous statement is here
           if (ret)
           ^
   1 warning generated.


vim +/if +88 drivers/clk/keystone/syscon-clk.c

1aa0817e43c525 Vignesh Raghavendra 2020-02-27  61  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  62  static struct clk_hw
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  63  *ti_syscon_gate_clk_register(struct device *dev, struct regmap *regmap,
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  64  			     const struct ti_syscon_gate_clk_data *data)
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  65  {
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  66  	struct ti_syscon_gate_clk_priv *priv;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  67  	struct clk_init_data init;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  68  	int ret;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  69  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  70  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  71  	if (!priv)
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  72  		return ERR_PTR(-ENOMEM);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  73  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  74  	init.name = data->name;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  75  	init.ops = &ti_syscon_gate_clk_ops;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  76  	init.parent_names = NULL;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  77  	init.num_parents = 0;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  78  	init.flags = 0;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  79  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  80  	priv->regmap = regmap;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  81  	priv->reg = data->offset;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  82  	priv->idx = BIT(data->bit_idx);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  83  	priv->hw.init = &init;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  84  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  85  	ret = devm_clk_hw_register(dev, &priv->hw);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  86  	if (ret)
c8db4a192822cd Yuanjun Gong        2022-07-22  87  		devm_kfree(dev, priv);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27 @88  		return ERR_PTR(ret);
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  89  
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  90  	return &priv->hw;
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  91  }
1aa0817e43c525 Vignesh Raghavendra 2020-02-27  92  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH 1/1] drivers/clk/keystone: avoid a memory leak
  2022-07-22  4:13 [PATCH 1/1] drivers/clk/keystone: avoid a memory leak Yuanjun Gong
  2022-07-23  1:53 ` kernel test robot
@ 2022-07-24  3:26 ` kernel test robot
  2022-07-24 15:08 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-07-24  3:26 UTC (permalink / raw)
  To: Yuanjun Gong, Santosh Shilimkar, linux-kernel; +Cc: kbuild-all

Hi Yuanjun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on keystone/next linus/master v5.19-rc7 next-20220722]
[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/Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm-randconfig-r024-20220721 (https://download.01.org/0day-ci/archive/20220724/202207241139.rWZLXU81-lkp@intel.com/config)
compiler: arm-linux-gnueabi-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/c8db4a192822cdb1e77a32238a893d7a81081f80
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
        git checkout c8db4a192822cdb1e77a32238a893d7a81081f80
        # 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=arm SHELL=/bin/bash drivers/clk/keystone/

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 >>):

   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from include/linux/of.h:15,
                    from include/linux/clk-provider.h:9,
                    from drivers/clk/keystone/syscon-clk.c:6:
   drivers/clk/keystone/syscon-clk.c: In function 'ti_syscon_gate_clk_register':
>> 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/keystone/syscon-clk.c:86:9: note: in expansion of macro 'if'
      86 |         if (ret)
         |         ^~
   drivers/clk/keystone/syscon-clk.c:88:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      88 |                 return ERR_PTR(ret);
         |                 ^~~~~~


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

2bcd521a684cc94 Steven Rostedt 2008-11-21  50  
2bcd521a684cc94 Steven Rostedt 2008-11-21  51  #ifdef CONFIG_PROFILE_ALL_BRANCHES
2bcd521a684cc94 Steven Rostedt 2008-11-21  52  /*
2bcd521a684cc94 Steven Rostedt 2008-11-21  53   * "Define 'is'", Bill Clinton
2bcd521a684cc94 Steven Rostedt 2008-11-21  54   * "Define 'if'", Steven Rostedt
2bcd521a684cc94 Steven Rostedt 2008-11-21  55   */
a15fd609ad53a63 Linus Torvalds 2019-03-20 @56  #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
a15fd609ad53a63 Linus Torvalds 2019-03-20  57  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH 1/1] drivers/clk/keystone: avoid a memory leak
  2022-07-22  4:13 [PATCH 1/1] drivers/clk/keystone: avoid a memory leak Yuanjun Gong
  2022-07-23  1:53 ` kernel test robot
  2022-07-24  3:26 ` kernel test robot
@ 2022-07-24 15:08 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-07-24 15:08 UTC (permalink / raw)
  To: Yuanjun Gong, Santosh Shilimkar, linux-kernel; +Cc: kbuild-all

Hi Yuanjun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v5.19-rc7 next-20220722]
[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/Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220724/202207242329.TdOMfM0N-lkp@intel.com/config)
compiler: arm-linux-gnueabi-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/c8db4a192822cdb1e77a32238a893d7a81081f80
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yuanjun-Gong/drivers-clk-keystone-avoid-a-memory-leak/20220722-121453
        git checkout c8db4a192822cdb1e77a32238a893d7a81081f80
        # 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=arm SHELL=/bin/bash drivers/clk/keystone/

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/clk/keystone/syscon-clk.c: In function 'ti_syscon_gate_clk_register':
>> drivers/clk/keystone/syscon-clk.c:86:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      86 |         if (ret)
         |         ^~
   drivers/clk/keystone/syscon-clk.c:88:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      88 |                 return ERR_PTR(ret);
         |                 ^~~~~~


vim +/if +86 drivers/clk/keystone/syscon-clk.c

1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  61  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  62  static struct clk_hw
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  63  *ti_syscon_gate_clk_register(struct device *dev, struct regmap *regmap,
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  64  			     const struct ti_syscon_gate_clk_data *data)
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  65  {
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  66  	struct ti_syscon_gate_clk_priv *priv;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  67  	struct clk_init_data init;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  68  	int ret;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  69  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  70  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  71  	if (!priv)
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  72  		return ERR_PTR(-ENOMEM);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  73  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  74  	init.name = data->name;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  75  	init.ops = &ti_syscon_gate_clk_ops;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  76  	init.parent_names = NULL;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  77  	init.num_parents = 0;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  78  	init.flags = 0;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  79  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  80  	priv->regmap = regmap;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  81  	priv->reg = data->offset;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  82  	priv->idx = BIT(data->bit_idx);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  83  	priv->hw.init = &init;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  84  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  85  	ret = devm_clk_hw_register(dev, &priv->hw);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27 @86  	if (ret)
c8db4a192822cdb1 Yuanjun Gong        2022-07-22  87  		devm_kfree(dev, priv);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  88  		return ERR_PTR(ret);
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  89  
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  90  	return &priv->hw;
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  91  }
1aa0817e43c525c3 Vignesh Raghavendra 2020-02-27  92  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

end of thread, other threads:[~2022-07-24 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22  4:13 [PATCH 1/1] drivers/clk/keystone: avoid a memory leak Yuanjun Gong
2022-07-23  1:53 ` kernel test robot
2022-07-24  3:26 ` kernel test robot
2022-07-24 15:08 ` kernel test robot

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.