mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure
@ 2026-09-13 10:26 Guangshuo Li
  2026-09-13 19:46 ` kernel test robot
  2026-09-13 19:46 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Guangshuo Li @ 2026-09-13 10:26 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	dri-devel, linux-kernel
  Cc: Guangshuo Li, stable

ili9881c_dsi_probe() registers the panel with drm_panel_add() before
attaching the DSI device. If mipi_dsi_attach() fails, probe returns the
error without removing the panel registration.

Since the remove callback is not called after a failed probe, the
panel remains registered and keeps an additional reference after the
devm-managed allocation is released, leaking the panel registration
and its reference.

Use devm_drm_panel_add() so that the panel registration is
automatically removed both on probe failure and on driver teardown.
Remove the now redundant drm_panel_remove() from the remove callback.

This issue was found by manual code inspection.

Fixes: 26aec25593c2 ("drm/panel: Add Ilitek ILI9881c panel driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index c3d5ab67121d..1a52f92e2963 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -2594,7 +2594,9 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
 	if (ret)
 		return ret;
 
-	drm_panel_add(&ctx->panel);
+	ret = devm_drm_panel_add(&dsi->dev, &ctx->panel);
+	if (ret)
+		return dev_err_probe(&dsi->dev, ret, "Failed to add panel\n")
 
 	dsi->mode_flags = ctx->desc->mode_flags;
 	dsi->format = MIPI_DSI_FMT_RGB888;
@@ -2605,10 +2607,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
 
 static void ili9881c_dsi_remove(struct mipi_dsi_device *dsi)
 {
-	struct ili9881c *ctx = mipi_dsi_get_drvdata(dsi);
-
 	mipi_dsi_detach(dsi);
-	drm_panel_remove(&ctx->panel);
 }
 
 static const struct ili9881c_desc lhr050h41_desc = {
-- 
2.43.0


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

* Re: [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure
  2026-09-13 10:26 [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure Guangshuo Li
@ 2026-09-13 19:46 ` kernel test robot
  2026-09-13 19:46 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-09-13 19:46 UTC (permalink / raw)
  To: Guangshuo Li, Neil Armstrong, Jessica Zhang, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Linus Walleij, dri-devel, linux-kernel
  Cc: llvm, oe-kbuild-all, Guangshuo Li, stable

Hi Guangshuo,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.3-rc2]
[cannot apply to drm-misc/drm-misc-next next-20260911]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guangshuo-Li/drm-panel-ilitek-ili9881c-fix-panel-cleanup-on-attach-failure/20260913-182608
base:   linus/master
patch link:    https://lore.kernel.org/r/20260913102608.1526916-1-lgs201920130244%40gmail.com
patch subject: [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure
config: riscv-randconfig-001-20260914 (https://download.01.org/0day-ci/archive/20260914/202609140343.MDs2yjJe-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260914/202609140343.MDs2yjJe-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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609140343.MDs2yjJe-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/gpu/drm/panel/panel-ilitek-ili9881c.c:15:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:27:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:12:
   In file included from arch/riscv/include/asm/io.h:148:
   include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
    1209 |         return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
         |                                                   ~~~~~~~~~~ ^
>> drivers/gpu/drm/panel/panel-ilitek-ili9881c.c:2599:64: error: expected ';' after return statement
    2599 |                 return dev_err_probe(&dsi->dev, ret, "Failed to add panel\n")
         |                                                                              ^
         |                                                                              ;
   1 warning and 1 error generated.


vim +2599 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c

  2545	
  2546	static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
  2547	{
  2548		struct ili9881c *ctx;
  2549		int ret;
  2550	
  2551		ctx = devm_drm_panel_alloc(&dsi->dev, struct ili9881c, panel, &ili9881c_funcs,
  2552					   DRM_MODE_CONNECTOR_DSI);
  2553		if (IS_ERR(ctx))
  2554			return PTR_ERR(ctx);
  2555	
  2556		mipi_dsi_set_drvdata(dsi, ctx);
  2557		ctx->dsi = dsi;
  2558		ctx->desc = of_device_get_match_data(&dsi->dev);
  2559	
  2560		ctx->power = devm_regulator_get(&dsi->dev, "power");
  2561		if (IS_ERR(ctx->power))
  2562			return dev_err_probe(&dsi->dev, PTR_ERR(ctx->power),
  2563					     "Couldn't get our power regulator\n");
  2564	
  2565		ctx->iovcc = devm_regulator_get_optional(&dsi->dev, "iovcc");
  2566		if (IS_ERR(ctx->iovcc)) {
  2567			if (PTR_ERR(ctx->iovcc) != -ENODEV)
  2568				return dev_err_probe(&dsi->dev, PTR_ERR(ctx->iovcc),
  2569					     "Couldn't get our iovcc regulator\n");
  2570			ctx->iovcc = NULL;
  2571		}
  2572	
  2573		ctx->reset = devm_gpiod_get_optional(&dsi->dev, "reset", GPIOD_OUT_LOW);
  2574		if (IS_ERR(ctx->reset))
  2575			return dev_err_probe(&dsi->dev, PTR_ERR(ctx->reset),
  2576					     "Couldn't get our reset GPIO\n");
  2577	
  2578		ret = drm_of_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);
  2579		if (ret) {
  2580			dev_err(&dsi->dev, "%pOF: failed to get orientation: %d\n",
  2581				dsi->dev.of_node, ret);
  2582			return ret;
  2583		}
  2584	
  2585		ctx->address_mode = ctx->desc->default_address_mode;
  2586		if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) {
  2587			ctx->address_mode ^= 0x03;
  2588			ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
  2589		}
  2590	
  2591		ctx->panel.prepare_prev_first = true;
  2592	
  2593		ret = drm_panel_of_backlight(&ctx->panel);
  2594		if (ret)
  2595			return ret;
  2596	
  2597		ret = devm_drm_panel_add(&dsi->dev, &ctx->panel);
  2598		if (ret)
> 2599			return dev_err_probe(&dsi->dev, ret, "Failed to add panel\n")
  2600	
  2601		dsi->mode_flags = ctx->desc->mode_flags;
  2602		dsi->format = MIPI_DSI_FMT_RGB888;
  2603		dsi->lanes = ctx->desc->lanes;
  2604	
  2605		return mipi_dsi_attach(dsi);
  2606	}
  2607	

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

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

* Re: [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure
  2026-09-13 10:26 [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure Guangshuo Li
  2026-09-13 19:46 ` kernel test robot
@ 2026-09-13 19:46 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-09-13 19:46 UTC (permalink / raw)
  To: Guangshuo Li, Neil Armstrong, Jessica Zhang, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Linus Walleij, dri-devel, linux-kernel
  Cc: oe-kbuild-all, Guangshuo Li, stable

Hi Guangshuo,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.3-rc2]
[cannot apply to drm-misc/drm-misc-next next-20260911]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guangshuo-Li/drm-panel-ilitek-ili9881c-fix-panel-cleanup-on-attach-failure/20260913-182608
base:   linus/master
patch link:    https://lore.kernel.org/r/20260913102608.1526916-1-lgs201920130244%40gmail.com
patch subject: [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure
config: parisc-randconfig-002-20260914 (https://download.01.org/0day-ci/archive/20260914/202609140335.bubtlivW-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260914/202609140335.bubtlivW-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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609140335.bubtlivW-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gpu/drm/panel/panel-ilitek-ili9881c.c: In function 'ili9881c_dsi_probe':
>> drivers/gpu/drm/panel/panel-ilitek-ili9881c.c:2599:78: error: expected ';' before 'dsi'
    2599 |                 return dev_err_probe(&dsi->dev, ret, "Failed to add panel\n")
         |                                                                              ^
         |                                                                              ;
    2600 | 
    2601 |         dsi->mode_flags = ctx->desc->mode_flags;
         |         ~~~                                                                   


vim +2599 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c

  2545	
  2546	static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
  2547	{
  2548		struct ili9881c *ctx;
  2549		int ret;
  2550	
  2551		ctx = devm_drm_panel_alloc(&dsi->dev, struct ili9881c, panel, &ili9881c_funcs,
  2552					   DRM_MODE_CONNECTOR_DSI);
  2553		if (IS_ERR(ctx))
  2554			return PTR_ERR(ctx);
  2555	
  2556		mipi_dsi_set_drvdata(dsi, ctx);
  2557		ctx->dsi = dsi;
  2558		ctx->desc = of_device_get_match_data(&dsi->dev);
  2559	
  2560		ctx->power = devm_regulator_get(&dsi->dev, "power");
  2561		if (IS_ERR(ctx->power))
  2562			return dev_err_probe(&dsi->dev, PTR_ERR(ctx->power),
  2563					     "Couldn't get our power regulator\n");
  2564	
  2565		ctx->iovcc = devm_regulator_get_optional(&dsi->dev, "iovcc");
  2566		if (IS_ERR(ctx->iovcc)) {
  2567			if (PTR_ERR(ctx->iovcc) != -ENODEV)
  2568				return dev_err_probe(&dsi->dev, PTR_ERR(ctx->iovcc),
  2569					     "Couldn't get our iovcc regulator\n");
  2570			ctx->iovcc = NULL;
  2571		}
  2572	
  2573		ctx->reset = devm_gpiod_get_optional(&dsi->dev, "reset", GPIOD_OUT_LOW);
  2574		if (IS_ERR(ctx->reset))
  2575			return dev_err_probe(&dsi->dev, PTR_ERR(ctx->reset),
  2576					     "Couldn't get our reset GPIO\n");
  2577	
  2578		ret = drm_of_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);
  2579		if (ret) {
  2580			dev_err(&dsi->dev, "%pOF: failed to get orientation: %d\n",
  2581				dsi->dev.of_node, ret);
  2582			return ret;
  2583		}
  2584	
  2585		ctx->address_mode = ctx->desc->default_address_mode;
  2586		if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) {
  2587			ctx->address_mode ^= 0x03;
  2588			ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
  2589		}
  2590	
  2591		ctx->panel.prepare_prev_first = true;
  2592	
  2593		ret = drm_panel_of_backlight(&ctx->panel);
  2594		if (ret)
  2595			return ret;
  2596	
  2597		ret = devm_drm_panel_add(&dsi->dev, &ctx->panel);
  2598		if (ret)
> 2599			return dev_err_probe(&dsi->dev, ret, "Failed to add panel\n")
  2600	
  2601		dsi->mode_flags = ctx->desc->mode_flags;
  2602		dsi->format = MIPI_DSI_FMT_RGB888;
  2603		dsi->lanes = ctx->desc->lanes;
  2604	
  2605		return mipi_dsi_attach(dsi);
  2606	}
  2607	

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

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

end of thread, other threads:[~2026-09-13 19:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13 10:26 [PATCH] drm/panel: ilitek-ili9881c: fix panel cleanup on attach failure Guangshuo Li
2026-09-13 19:46 ` kernel test robot
2026-09-13 19:46 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®