All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] of: Add missing of_node_put() before return
@ 2022-04-21 12:23 Wan Jiabing
  2022-04-21 12:34 ` Rob Herring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wan Jiabing @ 2022-04-21 12:23 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree, linux-kernel; +Cc: kael_w, Wan Jiabing

Fix the following coccicheck error:
drivers/of/platform.c:554:2-23: WARNING: Function "for_each_node_by_type"
should have of_node_put() before return around line 560.

Early exits from for_each_node_by_type() should decrement the node
reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/of/platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 2dff3a3d137c..3c7ca6671716 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -556,8 +556,10 @@ static int __init of_platform_default_populate_init(void)
 			    !of_get_property(node, "linux,boot-display", NULL))
 				continue;
 			dev = of_platform_device_create(node, "of-display", NULL);
-			if (WARN_ON(!dev))
+			if (WARN_ON(!dev)) {
+				of_node_put(node)
 				return -ENOMEM;
+			}
 			boot_display = node;
 			break;
 		}
-- 
2.35.1


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

* Re: [PATCH] of: Add missing of_node_put() before return
  2022-04-21 12:23 [PATCH] of: Add missing of_node_put() before return Wan Jiabing
@ 2022-04-21 12:34 ` Rob Herring
  2022-04-21 19:34 ` kernel test robot
  2022-04-21 19:54 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2022-04-21 12:34 UTC (permalink / raw)
  To: Wan Jiabing, Thomas Zimmermann
  Cc: Frank Rowand, devicetree, linux-kernel, kael_w

+Thomas

On Thu, Apr 21, 2022 at 7:23 AM Wan Jiabing <wanjiabing@vivo.com> wrote:
>
> Fix the following coccicheck error:
> drivers/of/platform.c:554:2-23: WARNING: Function "for_each_node_by_type"
> should have of_node_put() before return around line 560.

Especially since the code this fixes just landed, you should Cc the
author and reference the commit.

> Early exits from for_each_node_by_type() should decrement the node
> reference counter.
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
>  drivers/of/platform.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

This has to go via the DRM tree.

Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers")
Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH] of: Add missing of_node_put() before return
  2022-04-21 12:23 [PATCH] of: Add missing of_node_put() before return Wan Jiabing
  2022-04-21 12:34 ` Rob Herring
@ 2022-04-21 19:34 ` kernel test robot
  2022-04-21 19:54 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-04-21 19:34 UTC (permalink / raw)
  To: Wan Jiabing, Rob Herring, Frank Rowand, devicetree, linux-kernel
  Cc: kbuild-all, kael_w, Wan Jiabing

Hi Wan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220421]
[cannot apply to robh/for-next v5.18-rc3 v5.18-rc2 v5.18-rc1 v5.18-rc3]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Wan-Jiabing/of-Add-missing-of_node_put-before-return/20220421-202418
base:    65eb92e4c9f0a962656f131521f4fbc0d24c9d4c
config: i386-randconfig-a005 (https://download.01.org/0day-ci/archive/20220422/202204220349.GgbfoMrp-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/e54621b530fe295566dfa8bc3d3481e624c3ee01
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Wan-Jiabing/of-Add-missing-of_node_put-before-return/20220421-202418
        git checkout e54621b530fe295566dfa8bc3d3481e624c3ee01
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/

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

All errors (new ones prefixed by >>):

   drivers/of/platform.c: In function 'of_platform_default_populate_init':
>> drivers/of/platform.c:560:50: error: expected ';' before 'return'
     560 |                                 of_node_put(node)
         |                                                  ^
         |                                                  ;
     561 |                                 return -ENOMEM;
         |                                 ~~~~~~            


vim +560 drivers/of/platform.c

   515	
   516	static int __init of_platform_default_populate_init(void)
   517	{
   518		struct device_node *node;
   519	
   520		device_links_supplier_sync_state_pause();
   521	
   522		if (!of_have_populated_dt())
   523			return -ENODEV;
   524	
   525		if (IS_ENABLED(CONFIG_PPC)) {
   526			struct device_node *boot_display = NULL;
   527			struct platform_device *dev;
   528			int ret;
   529	
   530			/* Check if we have a MacOS display without a node spec */
   531			if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL)) {
   532				/*
   533				 * The old code tried to work out which node was the MacOS
   534				 * display based on the address. I'm dropping that since the
   535				 * lack of a node spec only happens with old BootX versions
   536				 * (users can update) and with this code, they'll still get
   537				 * a display (just not the palette hacks).
   538				 */
   539				dev = platform_device_alloc("bootx-noscreen", 0);
   540				if (WARN_ON(!dev))
   541					return -ENOMEM;
   542				ret = platform_device_add(dev);
   543				if (WARN_ON(ret)) {
   544					platform_device_put(dev);
   545					return ret;
   546				}
   547			}
   548	
   549			/*
   550			 * For OF framebuffers, first create the device for the boot display,
   551			 * then for the other framebuffers. Only fail for the boot display;
   552			 * ignore errors for the rest.
   553			 */
   554			for_each_node_by_type(node, "display") {
   555				if (!of_get_property(node, "linux,opened", NULL) ||
   556				    !of_get_property(node, "linux,boot-display", NULL))
   557					continue;
   558				dev = of_platform_device_create(node, "of-display", NULL);
   559				if (WARN_ON(!dev)) {
 > 560					of_node_put(node)
   561					return -ENOMEM;
   562				}
   563				boot_display = node;
   564				break;
   565			}
   566			for_each_node_by_type(node, "display") {
   567				if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
   568					continue;
   569				of_platform_device_create(node, "of-display", NULL);
   570			}
   571	
   572		} else {
   573			/*
   574			 * Handle certain compatibles explicitly, since we don't want to create
   575			 * platform_devices for every node in /reserved-memory with a
   576			 * "compatible",
   577			 */
   578			for_each_matching_node(node, reserved_mem_matches)
   579				of_platform_device_create(node, NULL, NULL);
   580	
   581			node = of_find_node_by_path("/firmware");
   582			if (node) {
   583				of_platform_populate(node, NULL, NULL, NULL);
   584				of_node_put(node);
   585			}
   586	
   587			node = of_get_compatible_child(of_chosen, "simple-framebuffer");
   588			of_platform_device_create(node, NULL, NULL);
   589			of_node_put(node);
   590	
   591			/* Populate everything else. */
   592			of_platform_default_populate(NULL, NULL, NULL);
   593		}
   594	
   595		return 0;
   596	}
   597	arch_initcall_sync(of_platform_default_populate_init);
   598	

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

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

* Re: [PATCH] of: Add missing of_node_put() before return
  2022-04-21 12:23 [PATCH] of: Add missing of_node_put() before return Wan Jiabing
  2022-04-21 12:34 ` Rob Herring
  2022-04-21 19:34 ` kernel test robot
@ 2022-04-21 19:54 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-04-21 19:54 UTC (permalink / raw)
  To: Wan Jiabing, Rob Herring, Frank Rowand, devicetree, linux-kernel
  Cc: llvm, kbuild-all, kael_w, Wan Jiabing

Hi Wan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220421]
[cannot apply to robh/for-next v5.18-rc3 v5.18-rc2 v5.18-rc1 v5.18-rc3]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Wan-Jiabing/of-Add-missing-of_node_put-before-return/20220421-202418
base:    65eb92e4c9f0a962656f131521f4fbc0d24c9d4c
config: hexagon-randconfig-r045-20220421 (https://download.01.org/0day-ci/archive/20220422/202204220341.c0TfAOVa-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project bac6cd5bf85669e3376610cfc4c4f9ca015e7b9b)
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/e54621b530fe295566dfa8bc3d3481e624c3ee01
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Wan-Jiabing/of-Add-missing-of_node_put-before-return/20220421-202418
        git checkout e54621b530fe295566dfa8bc3d3481e624c3ee01
        # 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=hexagon SHELL=/bin/bash drivers/

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

All errors (new ones prefixed by >>):

>> drivers/of/platform.c:560:22: error: expected ';' after expression
                                   of_node_put(node)
                                                    ^
                                                    ;
   1 error generated.


vim +560 drivers/of/platform.c

   515	
   516	static int __init of_platform_default_populate_init(void)
   517	{
   518		struct device_node *node;
   519	
   520		device_links_supplier_sync_state_pause();
   521	
   522		if (!of_have_populated_dt())
   523			return -ENODEV;
   524	
   525		if (IS_ENABLED(CONFIG_PPC)) {
   526			struct device_node *boot_display = NULL;
   527			struct platform_device *dev;
   528			int ret;
   529	
   530			/* Check if we have a MacOS display without a node spec */
   531			if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL)) {
   532				/*
   533				 * The old code tried to work out which node was the MacOS
   534				 * display based on the address. I'm dropping that since the
   535				 * lack of a node spec only happens with old BootX versions
   536				 * (users can update) and with this code, they'll still get
   537				 * a display (just not the palette hacks).
   538				 */
   539				dev = platform_device_alloc("bootx-noscreen", 0);
   540				if (WARN_ON(!dev))
   541					return -ENOMEM;
   542				ret = platform_device_add(dev);
   543				if (WARN_ON(ret)) {
   544					platform_device_put(dev);
   545					return ret;
   546				}
   547			}
   548	
   549			/*
   550			 * For OF framebuffers, first create the device for the boot display,
   551			 * then for the other framebuffers. Only fail for the boot display;
   552			 * ignore errors for the rest.
   553			 */
   554			for_each_node_by_type(node, "display") {
   555				if (!of_get_property(node, "linux,opened", NULL) ||
   556				    !of_get_property(node, "linux,boot-display", NULL))
   557					continue;
   558				dev = of_platform_device_create(node, "of-display", NULL);
   559				if (WARN_ON(!dev)) {
 > 560					of_node_put(node)
   561					return -ENOMEM;
   562				}
   563				boot_display = node;
   564				break;
   565			}
   566			for_each_node_by_type(node, "display") {
   567				if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
   568					continue;
   569				of_platform_device_create(node, "of-display", NULL);
   570			}
   571	
   572		} else {
   573			/*
   574			 * Handle certain compatibles explicitly, since we don't want to create
   575			 * platform_devices for every node in /reserved-memory with a
   576			 * "compatible",
   577			 */
   578			for_each_matching_node(node, reserved_mem_matches)
   579				of_platform_device_create(node, NULL, NULL);
   580	
   581			node = of_find_node_by_path("/firmware");
   582			if (node) {
   583				of_platform_populate(node, NULL, NULL, NULL);
   584				of_node_put(node);
   585			}
   586	
   587			node = of_get_compatible_child(of_chosen, "simple-framebuffer");
   588			of_platform_device_create(node, NULL, NULL);
   589			of_node_put(node);
   590	
   591			/* Populate everything else. */
   592			of_platform_default_populate(NULL, NULL, NULL);
   593		}
   594	
   595		return 0;
   596	}
   597	arch_initcall_sync(of_platform_default_populate_init);
   598	

-- 
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-04-21 19:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 12:23 [PATCH] of: Add missing of_node_put() before return Wan Jiabing
2022-04-21 12:34 ` Rob Herring
2022-04-21 19:34 ` kernel test robot
2022-04-21 19:54 ` 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.