All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
@ 2023-08-23  0:26 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-08-23  0:26 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Rob Herring <robh@kernel.org>
CC: Geert Uytterhoeven <geert+renesas@glider.be>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   89bf6209cad66214d3774dac86b6bbf2aec6a30d
commit: 914d9d831e6126a6e7a92e27fcfaa250671be42c of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
date:   34 hours ago
:::::: branch date: 6 hours ago
:::::: commit date: 34 hours ago
config: nios2-randconfig-r081-20230822 (https://download.01.org/0day-ci/archive/20230823/202308230814.2zOreL63-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230823/202308230814.2zOreL63-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202308230814.2zOreL63-lkp@intel.com/

smatch warnings:
drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'

vim +/ce +935 drivers/of/dynamic.c

183223770ae862 Gavin Shan        2015-11-05  907  
201c910bd6898d Pantelis Antoniou 2014-07-04  908  /**
0290c4ca2536a3 Frank Rowand      2017-10-17  909   * of_changeset_action - Add an action to the tail of the changeset list
201c910bd6898d Pantelis Antoniou 2014-07-04  910   *
201c910bd6898d Pantelis Antoniou 2014-07-04  911   * @ocs:	changeset pointer
201c910bd6898d Pantelis Antoniou 2014-07-04  912   * @action:	action to perform
201c910bd6898d Pantelis Antoniou 2014-07-04  913   * @np:		Pointer to device node
201c910bd6898d Pantelis Antoniou 2014-07-04  914   * @prop:	Pointer to property
201c910bd6898d Pantelis Antoniou 2014-07-04  915   *
201c910bd6898d Pantelis Antoniou 2014-07-04  916   * On action being one of:
201c910bd6898d Pantelis Antoniou 2014-07-04  917   * + OF_RECONFIG_ATTACH_NODE
201c910bd6898d Pantelis Antoniou 2014-07-04  918   * + OF_RECONFIG_DETACH_NODE,
201c910bd6898d Pantelis Antoniou 2014-07-04  919   * + OF_RECONFIG_ADD_PROPERTY
201c910bd6898d Pantelis Antoniou 2014-07-04  920   * + OF_RECONFIG_REMOVE_PROPERTY,
201c910bd6898d Pantelis Antoniou 2014-07-04  921   * + OF_RECONFIG_UPDATE_PROPERTY
8c8239c2c1fb82 Rob Herring       2021-03-25  922   *
8c8239c2c1fb82 Rob Herring       2021-03-25  923   * Return: 0 on success, a negative error value in case of an error.
201c910bd6898d Pantelis Antoniou 2014-07-04  924   */
201c910bd6898d Pantelis Antoniou 2014-07-04  925  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
201c910bd6898d Pantelis Antoniou 2014-07-04  926  		struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04  927  {
201c910bd6898d Pantelis Antoniou 2014-07-04  928  	struct of_changeset_entry *ce;
201c910bd6898d Pantelis Antoniou 2014-07-04  929  
201c910bd6898d Pantelis Antoniou 2014-07-04  930  	ce = kzalloc(sizeof(*ce), GFP_KERNEL);
606ad42aa3b1fe Rob Herring       2016-06-15  931  	if (!ce)
201c910bd6898d Pantelis Antoniou 2014-07-04  932  		return -ENOMEM;
606ad42aa3b1fe Rob Herring       2016-06-15  933  
914d9d831e6126 Rob Herring       2023-08-18  934  	if (WARN_ON(action >= ARRAY_SIZE(action_names)))
914d9d831e6126 Rob Herring       2023-08-18 @935  		return -EINVAL;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
@ 2023-09-01  2:22 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-09-01  2:22 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Rob Herring <robh@kernel.org>
CC: Geert Uytterhoeven <geert+renesas@glider.be>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
commit: 914d9d831e6126a6e7a92e27fcfaa250671be42c of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
date:   11 days ago
:::::: branch date: 4 hours ago
:::::: commit date: 11 days ago
config: x86_64-randconfig-161-20230831 (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202309011059.EOdr4im9-lkp@intel.com/

smatch warnings:
drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'

vim +/ce +935 drivers/of/dynamic.c

183223770ae862 Gavin Shan        2015-11-05  907  
201c910bd6898d Pantelis Antoniou 2014-07-04  908  /**
0290c4ca2536a3 Frank Rowand      2017-10-17  909   * of_changeset_action - Add an action to the tail of the changeset list
201c910bd6898d Pantelis Antoniou 2014-07-04  910   *
201c910bd6898d Pantelis Antoniou 2014-07-04  911   * @ocs:	changeset pointer
201c910bd6898d Pantelis Antoniou 2014-07-04  912   * @action:	action to perform
201c910bd6898d Pantelis Antoniou 2014-07-04  913   * @np:		Pointer to device node
201c910bd6898d Pantelis Antoniou 2014-07-04  914   * @prop:	Pointer to property
201c910bd6898d Pantelis Antoniou 2014-07-04  915   *
201c910bd6898d Pantelis Antoniou 2014-07-04  916   * On action being one of:
201c910bd6898d Pantelis Antoniou 2014-07-04  917   * + OF_RECONFIG_ATTACH_NODE
201c910bd6898d Pantelis Antoniou 2014-07-04  918   * + OF_RECONFIG_DETACH_NODE,
201c910bd6898d Pantelis Antoniou 2014-07-04  919   * + OF_RECONFIG_ADD_PROPERTY
201c910bd6898d Pantelis Antoniou 2014-07-04  920   * + OF_RECONFIG_REMOVE_PROPERTY,
201c910bd6898d Pantelis Antoniou 2014-07-04  921   * + OF_RECONFIG_UPDATE_PROPERTY
8c8239c2c1fb82 Rob Herring       2021-03-25  922   *
8c8239c2c1fb82 Rob Herring       2021-03-25  923   * Return: 0 on success, a negative error value in case of an error.
201c910bd6898d Pantelis Antoniou 2014-07-04  924   */
201c910bd6898d Pantelis Antoniou 2014-07-04  925  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
201c910bd6898d Pantelis Antoniou 2014-07-04  926  		struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04  927  {
201c910bd6898d Pantelis Antoniou 2014-07-04  928  	struct of_changeset_entry *ce;
201c910bd6898d Pantelis Antoniou 2014-07-04  929  
201c910bd6898d Pantelis Antoniou 2014-07-04  930  	ce = kzalloc(sizeof(*ce), GFP_KERNEL);
606ad42aa3b1fe Rob Herring       2016-06-15  931  	if (!ce)
201c910bd6898d Pantelis Antoniou 2014-07-04  932  		return -ENOMEM;
606ad42aa3b1fe Rob Herring       2016-06-15  933  
914d9d831e6126 Rob Herring       2023-08-18  934  	if (WARN_ON(action >= ARRAY_SIZE(action_names)))
914d9d831e6126 Rob Herring       2023-08-18 @935  		return -EINVAL;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
@ 2023-09-07 10:52 Dan Carpenter
  2023-09-07 11:30 ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-09-07 10:52 UTC (permalink / raw)
  To: oe-kbuild, Rob Herring
  Cc: lkp, oe-kbuild-all, linux-kernel, Geert Uytterhoeven

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
commit: 914d9d831e6126a6e7a92e27fcfaa250671be42c of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
config: x86_64-randconfig-161-20230831 (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202309011059.EOdr4im9-lkp@intel.com/

smatch warnings:
drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'

vim +/ce +935 drivers/of/dynamic.c

201c910bd6898d Pantelis Antoniou 2014-07-04  925  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
201c910bd6898d Pantelis Antoniou 2014-07-04  926  		struct device_node *np, struct property *prop)
201c910bd6898d Pantelis Antoniou 2014-07-04  927  {
201c910bd6898d Pantelis Antoniou 2014-07-04  928  	struct of_changeset_entry *ce;
201c910bd6898d Pantelis Antoniou 2014-07-04  929  
201c910bd6898d Pantelis Antoniou 2014-07-04  930  	ce = kzalloc(sizeof(*ce), GFP_KERNEL);
606ad42aa3b1fe Rob Herring       2016-06-15  931  	if (!ce)
201c910bd6898d Pantelis Antoniou 2014-07-04  932  		return -ENOMEM;
606ad42aa3b1fe Rob Herring       2016-06-15  933  
914d9d831e6126 Rob Herring       2023-08-18  934  	if (WARN_ON(action >= ARRAY_SIZE(action_names)))
914d9d831e6126 Rob Herring       2023-08-18 @935  		return -EINVAL;

No kfree(ce).  Probably we move this check before the kmalloc()?

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

* Re: drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
  2023-09-07 10:52 Dan Carpenter
@ 2023-09-07 11:30 ` Geert Uytterhoeven
  2023-09-07 11:47   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2023-09-07 11:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, Rob Herring, lkp, oe-kbuild-all, linux-kernel

Hi Dan,

On Thu, Sep 7, 2023 at 12:52 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
> commit: 914d9d831e6126a6e7a92e27fcfaa250671be42c of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
> config: x86_64-randconfig-161-20230831 (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202309011059.EOdr4im9-lkp@intel.com/
>
> smatch warnings:
> drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
>
> vim +/ce +935 drivers/of/dynamic.c
>
> 201c910bd6898d Pantelis Antoniou 2014-07-04  925  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
> 201c910bd6898d Pantelis Antoniou 2014-07-04  926                struct device_node *np, struct property *prop)
> 201c910bd6898d Pantelis Antoniou 2014-07-04  927  {
> 201c910bd6898d Pantelis Antoniou 2014-07-04  928        struct of_changeset_entry *ce;
> 201c910bd6898d Pantelis Antoniou 2014-07-04  929
> 201c910bd6898d Pantelis Antoniou 2014-07-04  930        ce = kzalloc(sizeof(*ce), GFP_KERNEL);
> 606ad42aa3b1fe Rob Herring       2016-06-15  931        if (!ce)
> 201c910bd6898d Pantelis Antoniou 2014-07-04  932                return -ENOMEM;
> 606ad42aa3b1fe Rob Herring       2016-06-15  933
> 914d9d831e6126 Rob Herring       2023-08-18  934        if (WARN_ON(action >= ARRAY_SIZE(action_names)))
> 914d9d831e6126 Rob Herring       2023-08-18 @935                return -EINVAL;
>
> No kfree(ce).  Probably we move this check before the kmalloc()?

Yes, moving up sounds great.
Care to send a patch?

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
  2023-09-07 11:30 ` Geert Uytterhoeven
@ 2023-09-07 11:47   ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2023-09-07 11:47 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: oe-kbuild, Rob Herring, lkp, oe-kbuild-all, linux-kernel

On Thu, Sep 07, 2023 at 01:30:09PM +0200, Geert Uytterhoeven wrote:
> Hi Dan,
> 
> On Thu, Sep 7, 2023 at 12:52 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   99d99825fc075fd24b60cc9cf0fb1e20b9c16b0f
> > commit: 914d9d831e6126a6e7a92e27fcfaa250671be42c of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock
> > config: x86_64-randconfig-161-20230831 (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/config)
> > compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> > reproduce: (https://download.01.org/0day-ci/archive/20230901/202309011059.EOdr4im9-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > | Closes: https://lore.kernel.org/r/202309011059.EOdr4im9-lkp@intel.com/
> >
> > smatch warnings:
> > drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce'
> >
> > vim +/ce +935 drivers/of/dynamic.c
> >
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  925  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  926                struct device_node *np, struct property *prop)
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  927  {
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  928        struct of_changeset_entry *ce;
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  929
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  930        ce = kzalloc(sizeof(*ce), GFP_KERNEL);
> > 606ad42aa3b1fe Rob Herring       2016-06-15  931        if (!ce)
> > 201c910bd6898d Pantelis Antoniou 2014-07-04  932                return -ENOMEM;
> > 606ad42aa3b1fe Rob Herring       2016-06-15  933
> > 914d9d831e6126 Rob Herring       2023-08-18  934        if (WARN_ON(action >= ARRAY_SIZE(action_names)))
> > 914d9d831e6126 Rob Herring       2023-08-18 @935                return -EINVAL;
> >
> > No kfree(ce).  Probably we move this check before the kmalloc()?
> 
> Yes, moving up sounds great.
> Care to send a patch?
> 

Sure.  I can do that.

These are zero day bot warnings from Intel.  I normally just look them
over and hit the forward button.  Quite often the zero day bot will find
the warnings before the patch has been apply.  But in this case, it's
simple enough to patch.

regards,
dan carpenter


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

end of thread, other threads:[~2023-09-07 11:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23  0:26 drivers/of/dynamic.c:935 of_changeset_action() warn: possible memory leak of 'ce' kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-09-01  2:22 kernel test robot
2023-09-07 10:52 Dan Carpenter
2023-09-07 11:30 ` Geert Uytterhoeven
2023-09-07 11:47   ` Dan Carpenter

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.