All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
@ 2024-04-19 11:36 Aleksandr Mishin
  2024-04-19 15:02 ` Dmitry Baryshkov
  2024-04-19 19:47 ` Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Aleksandr Mishin @ 2024-04-19 11:36 UTC (permalink / raw)
  To: Robert Foss
  Cc: Aleksandr Mishin, Swapnil Jakhade, Andrzej Hajda, Neil Armstrong,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Tomi Valkeinen, Uwe Kleine-König,
	Nikhil Devshatwar, Aradhya Bhatia, Jani Nikula, Rob Herring,
	Zhu Wang, Yuti Amonkar, Jyri Sarha, Quentin Schulz, dri-devel,
	linux-kernel, lvc-project

In cdns_mhdp_atomic_enable(), there is an error return on failure of
drm_mode_duplicate() which leads to the mutex remaining locked.
Add a mutex unlock call.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 935a92a1c400 ("drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
This patch is against drm-misc-next branch of drm-misc repo.

 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 8a91ef0ae065..65a4bd09d9c6 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -2059,8 +2059,10 @@ static void cdns_mhdp_atomic_enable(struct drm_bridge *bridge,
 	mhdp_state = to_cdns_mhdp_bridge_state(new_state);
 
 	mhdp_state->current_mode = drm_mode_duplicate(bridge->dev, mode);
-	if (!mhdp_state->current_mode)
-		return;
+	if (!mhdp_state->current_mode) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	drm_mode_set_name(mhdp_state->current_mode);
 
-- 
2.30.2


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

* Re: [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
  2024-04-19 11:36 Aleksandr Mishin
@ 2024-04-19 15:02 ` Dmitry Baryshkov
  2024-04-19 19:47 ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2024-04-19 15:02 UTC (permalink / raw)
  To: Aleksandr Mishin
  Cc: Robert Foss, Swapnil Jakhade, Andrzej Hajda, Neil Armstrong,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Tomi Valkeinen, Uwe Kleine-König,
	Nikhil Devshatwar, Aradhya Bhatia, Jani Nikula, Rob Herring,
	Zhu Wang, Yuti Amonkar, Jyri Sarha, Quentin Schulz, dri-devel,
	linux-kernel, lvc-project

On Fri, Apr 19, 2024 at 02:36:37PM +0300, Aleksandr Mishin wrote:
> In cdns_mhdp_atomic_enable(), there is an error return on failure of
> drm_mode_duplicate() which leads to the mutex remaining locked.
> Add a mutex unlock call.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 935a92a1c400 ("drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
> ---
> This patch is against drm-misc-next branch of drm-misc repo.
> 
>  drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> 


Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


-- 
With best wishes
Dmitry

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

* Re: [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
  2024-04-19 11:36 Aleksandr Mishin
  2024-04-19 15:02 ` Dmitry Baryshkov
@ 2024-04-19 19:47 ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-04-19 19:47 UTC (permalink / raw)
  To: Aleksandr Mishin, dri-devel, lvc-project, kernel-janitors,
	Robert Foss, Dmitry Baryshkov
  Cc: LKML, Andrzej Hajda, Aradhya Bhatia, Daniel Vetter, David Airlie,
	Jani Nikula, Jernej Skrabec, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Maarten Lankhorst, Maxime Ripard,
	Neil Armstrong, Nikhil Devshatwar, Quentin Schulz, Rob Herring,
	Swapnil Jakhade, Thomas Zimmermann, Tomi Valkeinen,
	Uwe Kleine-König, Yuti Amonkar, Zhu Wang

…
> Add a mutex unlock call.

How do you think about a wording variant like the following?

   Extend the exception handling so that the missed mutex_unlock() call
   will be performed finally.


Regards,
Markus

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

* [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
@ 2025-09-04  3:44 Qi Xi
  2025-09-09 13:59 ` Luca Ceresoli
  2025-09-16 13:52 ` Luca Ceresoli
  0 siblings, 2 replies; 6+ messages in thread
From: Qi Xi @ 2025-09-04  3:44 UTC (permalink / raw)
  To: bobo.shaobowang, xiqi2, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, lumag, dianders, lyude,
	luca.ceresoli, andy.yan, viro, mordan, amishin, dri-devel
  Cc: linux-kernel

Add missing mutex unlock before returning from the error path in
cdns_mhdp_atomic_enable().

Fixes: 935a92a1c400 ("drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index a614d1384f71..38726ae1bf15 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -1984,8 +1984,10 @@ static void cdns_mhdp_atomic_enable(struct drm_bridge *bridge,
 	mhdp_state = to_cdns_mhdp_bridge_state(new_state);
 
 	mhdp_state->current_mode = drm_mode_duplicate(bridge->dev, mode);
-	if (!mhdp_state->current_mode)
-		return;
+	if (!mhdp_state->current_mode) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	drm_mode_set_name(mhdp_state->current_mode);
 
-- 
2.33.0


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

* Re: [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
  2025-09-04  3:44 [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path Qi Xi
@ 2025-09-09 13:59 ` Luca Ceresoli
  2025-09-16 13:52 ` Luca Ceresoli
  1 sibling, 0 replies; 6+ messages in thread
From: Luca Ceresoli @ 2025-09-09 13:59 UTC (permalink / raw)
  To: Qi Xi
  Cc: bobo.shaobowang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, lumag, dianders, lyude,
	andy.yan, viro, mordan, amishin, dri-devel, linux-kernel

Hello Qi Xi,

On Thu, 4 Sep 2025 11:44:47 +0800
Qi Xi <xiqi2@huawei.com> wrote:

> Add missing mutex unlock before returning from the error path in
> cdns_mhdp_atomic_enable().
> 
> Fixes: 935a92a1c400 ("drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Qi Xi <xiqi2@huawei.com>

Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
  2025-09-04  3:44 [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path Qi Xi
  2025-09-09 13:59 ` Luca Ceresoli
@ 2025-09-16 13:52 ` Luca Ceresoli
  1 sibling, 0 replies; 6+ messages in thread
From: Luca Ceresoli @ 2025-09-16 13:52 UTC (permalink / raw)
  To: bobo.shaobowang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, lumag, dianders, lyude,
	andy.yan, viro, mordan, amishin, dri-devel, Qi Xi
  Cc: linux-kernel


On Thu, 04 Sep 2025 11:44:47 +0800, Qi Xi wrote:
> Add missing mutex unlock before returning from the error path in
> cdns_mhdp_atomic_enable().
> 
> 

Applied, thanks!

[1/1] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path
      commit: 288dac9fb6084330d968459c750c838fd06e10e6

Best regards,
-- 
Luca Ceresoli <luca.ceresoli@bootlin.com>


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

end of thread, other threads:[~2025-09-16 13:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04  3:44 [PATCH] drm: bridge: cdns-mhdp8546: Fix missing mutex unlock on error path Qi Xi
2025-09-09 13:59 ` Luca Ceresoli
2025-09-16 13:52 ` Luca Ceresoli
  -- strict thread matches above, loose matches on Subject: below --
2024-04-19 11:36 Aleksandr Mishin
2024-04-19 15:02 ` Dmitry Baryshkov
2024-04-19 19:47 ` Markus Elfring

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.