[PATCH] drm/kmb: fix potential memleak in error branch

kernel test robot lkp at intel.com
Mon Nov 22 07:12:23 UTC 2021


Hi Bernard,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v5.16-rc2 next-20211118]
[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/Bernard-Zhao/drm-kmb-fix-potential-memleak-in-error-branch/20211118-103810
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: hexagon-randconfig-r016-20211118 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c46becf500df2a7fb4b4fce16178a036c344315a)
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/bbd8ae6a806e8e9e31c362a76ab4ba02a43b4694
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bernard-Zhao/drm-kmb-fix-potential-memleak-in-error-branch/20211118-103810
        git checkout bbd8ae6a806e8e9e31c362a76ab4ba02a43b4694
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=hexagon 

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

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/kmb/kmb_drv.c:517:3: error: implicit declaration of function 'of_dev_put' [-Werror,-Wimplicit-function-declaration]
                   of_dev_put(dsi_pdev);
                   ^
   drivers/gpu/drm/kmb/kmb_drv.c:520:3: error: implicit declaration of function 'of_dev_put' [-Werror,-Wimplicit-function-declaration]
                   of_dev_put(dsi_pdev);
                   ^
   drivers/gpu/drm/kmb/kmb_drv.c:529:3: error: implicit declaration of function 'of_dev_put' [-Werror,-Wimplicit-function-declaration]
                   of_dev_put(dsi_pdev);
                   ^
   drivers/gpu/drm/kmb/kmb_drv.c:579:2: error: implicit declaration of function 'of_dev_put' [-Werror,-Wimplicit-function-declaration]
           of_dev_put(dsi_pdev);
           ^
   4 errors generated.


vim +/of_dev_put +517 drivers/gpu/drm/kmb/kmb_drv.c

   475	
   476	static int kmb_probe(struct platform_device *pdev)
   477	{
   478		struct device *dev = get_device(&pdev->dev);
   479		struct kmb_drm_private *kmb;
   480		int ret = 0;
   481		struct device_node *dsi_in;
   482		struct device_node *dsi_node;
   483		struct platform_device *dsi_pdev;
   484	
   485		/* The bridge (ADV 7535) will return -EPROBE_DEFER until it
   486		 * has a mipi_dsi_host to register its device to. So, we
   487		 * first register the DSI host during probe time, and then return
   488		 * -EPROBE_DEFER until the bridge is loaded. Probe will be called again
   489		 *  and then the rest of the driver initialization can proceed
   490		 *  afterwards and the bridge can be successfully attached.
   491		 */
   492		dsi_in = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
   493		if (!dsi_in) {
   494			DRM_ERROR("Failed to get dsi_in node info from DT");
   495			return -EINVAL;
   496		}
   497		dsi_node = of_graph_get_remote_port_parent(dsi_in);
   498		if (!dsi_node) {
   499			of_node_put(dsi_in);
   500			DRM_ERROR("Failed to get dsi node from DT\n");
   501			return -EINVAL;
   502		}
   503	
   504		dsi_pdev = of_find_device_by_node(dsi_node);
   505		if (!dsi_pdev) {
   506			of_node_put(dsi_in);
   507			of_node_put(dsi_node);
   508			DRM_ERROR("Failed to get dsi platform device\n");
   509			return -EINVAL;
   510		}
   511	
   512		of_node_put(dsi_in);
   513		of_node_put(dsi_node);
   514		ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev));
   515	
   516		if (ret == -EPROBE_DEFER) {
 > 517			of_dev_put(dsi_pdev);
   518			return -EPROBE_DEFER;
   519		} else if (ret) {
   520			of_dev_put(dsi_pdev);
   521			DRM_ERROR("probe failed to initialize DSI host bridge\n");
   522			return ret;
   523		}
   524	
   525		/* Create DRM device */
   526		kmb = devm_drm_dev_alloc(dev, &kmb_driver,
   527					 struct kmb_drm_private, drm);
   528		if (IS_ERR(kmb)) {
   529			of_dev_put(dsi_pdev);
   530			return PTR_ERR(kmb);
   531		}
   532	
   533		dev_set_drvdata(dev, &kmb->drm);
   534	
   535		/* Initialize MIPI DSI */
   536		kmb->kmb_dsi = kmb_dsi_init(dsi_pdev);
   537		if (IS_ERR(kmb->kmb_dsi)) {
   538			drm_err(&kmb->drm, "failed to initialize DSI\n");
   539			ret = PTR_ERR(kmb->kmb_dsi);
   540			goto err_free1;
   541		}
   542	
   543		kmb->kmb_dsi->dev = &dsi_pdev->dev;
   544		kmb->kmb_dsi->pdev = dsi_pdev;
   545		ret = kmb_hw_init(&kmb->drm, 0);
   546		if (ret)
   547			goto err_free1;
   548	
   549		ret = kmb_setup_mode_config(&kmb->drm);
   550		if (ret)
   551			goto err_free;
   552	
   553		ret = kmb_irq_install(&kmb->drm, kmb->irq_lcd);
   554		if (ret < 0) {
   555			drm_err(&kmb->drm, "failed to install IRQ handler\n");
   556			goto err_irq;
   557		}
   558	
   559		drm_kms_helper_poll_init(&kmb->drm);
   560	
   561		/* Register graphics device with the kernel */
   562		ret = drm_dev_register(&kmb->drm, 0);
   563		if (ret)
   564			goto err_register;
   565	
   566		return 0;
   567	
   568	 err_register:
   569		drm_kms_helper_poll_fini(&kmb->drm);
   570	 err_irq:
   571		pm_runtime_disable(kmb->drm.dev);
   572	 err_free:
   573		drm_crtc_cleanup(&kmb->crtc);
   574		drm_mode_config_cleanup(&kmb->drm);
   575	 err_free1:
   576		dev_set_drvdata(dev, NULL);
   577		kmb_dsi_host_unregister(kmb->kmb_dsi);
   578	
   579		of_dev_put(dsi_pdev);
   580	
   581		return ret;
   582	}
   583	

---
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: 23770 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20211122/e660a423/attachment-0001.gz>


More information about the dri-devel mailing list