[PATCH] drm: of: fix leak of port_node

kernel test robot lkp at intel.com
Sat Sep 26 01:56:37 UTC 2020


Hi Tobias,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.9-rc6 next-20200925]
[cannot apply to drm/drm-next]
[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/0day-ci/linux/commits/Tobias-Jordan/drm-of-fix-leak-of-port_node/20200926-063854
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.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/0day-ci/linux/commit/9acba5320ef136e5d4a3b7563f4b5a362922c818
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tobias-Jordan/drm-of-fix-leak-of-port_node/20200926-063854
        git checkout 9acba5320ef136e5d4a3b7563f4b5a362922c818
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa 

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

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/drm_of.c: In function 'drm_of_lvds_get_remote_pixels_type':
>> drivers/gpu/drm/drm_of.c:318:16: warning: passing argument 1 of 'of_node_put' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     318 |    of_node_put(port_node);
         |                ^~~~~~~~~
   In file included from include/linux/irqdomain.h:35,
                    from include/linux/acpi.h:13,
                    from include/linux/i2c.h:13,
                    from include/drm/drm_crtc.h:28,
                    from include/drm/drm_atomic.h:31,
                    from include/drm/drm_bridge.h:30,
                    from drivers/gpu/drm/drm_of.c:7:
   include/linux/of.h:122:45: note: expected 'struct device_node *' but argument is of type 'const struct device_node *'
     122 | extern void of_node_put(struct device_node *node);
         |                         ~~~~~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/drm_of.c:335:16: warning: passing argument 1 of 'of_node_put' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     335 |    of_node_put(port_node);
         |                ^~~~~~~~~
   In file included from include/linux/irqdomain.h:35,
                    from include/linux/acpi.h:13,
                    from include/linux/i2c.h:13,
                    from include/drm/drm_crtc.h:28,
                    from include/drm/drm_atomic.h:31,
                    from include/drm/drm_bridge.h:30,
                    from drivers/gpu/drm/drm_of.c:7:
   include/linux/of.h:122:45: note: expected 'struct device_node *' but argument is of type 'const struct device_node *'
     122 | extern void of_node_put(struct device_node *node);
         |                         ~~~~~~~~~~~~~~~~~~~~^~~~

vim +318 drivers/gpu/drm/drm_of.c

   302	
   303	static int drm_of_lvds_get_remote_pixels_type(
   304				const struct device_node *port_node)
   305	{
   306		struct device_node *endpoint = NULL;
   307		int pixels_type = -EPIPE;
   308	
   309		for_each_child_of_node(port_node, endpoint) {
   310			struct device_node *remote_port;
   311			int current_pt;
   312	
   313			if (!of_node_name_eq(endpoint, "endpoint"))
   314				continue;
   315	
   316			remote_port = of_graph_get_remote_port(endpoint);
   317			if (!remote_port) {
 > 318				of_node_put(port_node);
   319				return -EPIPE;
   320			}
   321	
   322			current_pt = drm_of_lvds_get_port_pixels_type(remote_port);
   323			of_node_put(remote_port);
   324			if (pixels_type < 0)
   325				pixels_type = current_pt;
   326	
   327			/*
   328			 * Sanity check, ensure that all remote endpoints have the same
   329			 * pixel type. We may lift this restriction later if we need to
   330			 * support multiple sinks with different dual-link
   331			 * configurations by passing the endpoints explicitly to
   332			 * drm_of_lvds_get_dual_link_pixel_order().
   333			 */
   334			if (!current_pt || pixels_type != current_pt) {
   335				of_node_put(port_node);
   336				return -EINVAL;
   337			}
   338		}
   339	
   340		return pixels_type;
   341	}
   342	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 65123 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20200926/317a9875/attachment-0001.gz>


More information about the dri-devel mailing list