Re: [PATCH] drm: of: fix leak of port_node

From: kernel test robot
Date: Sat Sep 26 2020 - 15:24:03 EST


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: i386-randconfig-s001-20200925 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-201-g24bdaac6-dirty
# 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
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

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


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/drm_of.c:318:37: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected struct device_node *node @@ got struct device_node const *port_node @@
>> drivers/gpu/drm/drm_of.c:318:37: sparse: expected struct device_node *node
>> drivers/gpu/drm/drm_of.c:318:37: sparse: got struct device_node const *port_node
drivers/gpu/drm/drm_of.c:335:37: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected struct device_node *node @@ got struct device_node const *port_node @@
drivers/gpu/drm/drm_of.c:335:37: sparse: expected struct device_node *node
drivers/gpu/drm/drm_of.c:335:37: sparse: got struct device_node const *port_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@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip