[PATCH] drm: bridge: anx7625: don't crash if Type-C port is not used

Dmitry Baryshkov posted 1 patch 1 month, 2 weeks ago
drivers/gpu/drm/bridge/analogix/anx7625.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] drm: bridge: anx7625: don't crash if Type-C port is not used
Posted by Dmitry Baryshkov 1 month, 2 weeks ago
From: Loic Poulain <loic.poulain@oss.qualcomm.com>

The typec_set_*() functions do not tolerate being passed the NULL
typec_port instance. However, if CONFIG_TYPEC is enabled, but anx7625
DT node doesn't have the usb-c connector fwnode, then typec_port remains
NULL, crashing the kernel. Prevent calling typec_set_foo() functions by
checking that ctx->typec_port is not NULL in anx7625_typec_set_status().

 Call trace:
  typec_set_orientation+0x18/0x68 (P)
  anx7625_typec_set_status+0x108/0x13c
  anx7625_work_func+0x124/0x438
  process_one_work+0x214/0x648
  worker_thread+0x1b4/0x358
  kthread+0x14c/0x214
  ret_from_fork+0x10/0x20
 Code: 910003fd a90153f3 aa0003f3 2a0103f4 (f9431400)

Fixes: f81455b2d332 ("drm: bridge: anx7625: implement minimal Type-C support")
Reported-by: Salendarsingh Gaud <sgaud@qti.qualcomm.com>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
[db: dropped chunk anx7625_typec_unregister(), wrote commit message]
Cc: Amit Kucheria <akucheri@qti.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index c43519097a45..7f943b6548f3 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1567,6 +1567,9 @@ static void anx7625_typec_set_status(struct anx7625_data *ctx,
 				     unsigned int intr_status,
 				     unsigned int intr_vector)
 {
+	if (!ctx->typec_port)
+		return;
+
 	if (intr_vector & CC_STATUS)
 		anx7625_typec_set_orientation(ctx);
 	if (intr_vector & DATA_ROLE_STATUS) {

---
base-commit: 400a84e1f7a3681ef24d58d49b5d07e81c14f4e9
change-id: 20260215-anx-fix-no-typec-4437cb7e54d2

Best regards,
-- 
With best wishes
Dmitry
Re: [PATCH] drm: bridge: anx7625: don't crash if Type-C port is not used
Posted by Dmitry Baryshkov 3 weeks, 1 day ago
On Sun, 15 Feb 2026 03:30:02 +0200, Dmitry Baryshkov wrote:
> The typec_set_*() functions do not tolerate being passed the NULL
> typec_port instance. However, if CONFIG_TYPEC is enabled, but anx7625
> DT node doesn't have the usb-c connector fwnode, then typec_port remains
> NULL, crashing the kernel. Prevent calling typec_set_foo() functions by
> checking that ctx->typec_port is not NULL in anx7625_typec_set_status().
> 
>  Call trace:
>   typec_set_orientation+0x18/0x68 (P)
>   anx7625_typec_set_status+0x108/0x13c
>   anx7625_work_func+0x124/0x438
>   process_one_work+0x214/0x648
>   worker_thread+0x1b4/0x358
>   kthread+0x14c/0x214
>   ret_from_fork+0x10/0x20
>  Code: 910003fd a90153f3 aa0003f3 2a0103f4 (f9431400)
> 
> [...]

Applied to drm-misc-next, thanks!

[1/1] drm: bridge: anx7625: don't crash if Type-C port is not used
      commit: 8e3d8b33859bb8229d1f0b88752cbecb4932790a

Best regards,
-- 
With best wishes
Dmitry
Re: [PATCH] drm: bridge: anx7625: don't crash if Type-C port is not used
Posted by Neil Armstrong 3 weeks, 6 days ago
On 2/15/26 02:30, Dmitry Baryshkov wrote:
> From: Loic Poulain <loic.poulain@oss.qualcomm.com>
> 
> The typec_set_*() functions do not tolerate being passed the NULL
> typec_port instance. However, if CONFIG_TYPEC is enabled, but anx7625
> DT node doesn't have the usb-c connector fwnode, then typec_port remains
> NULL, crashing the kernel. Prevent calling typec_set_foo() functions by
> checking that ctx->typec_port is not NULL in anx7625_typec_set_status().
> 
>   Call trace:
>    typec_set_orientation+0x18/0x68 (P)
>    anx7625_typec_set_status+0x108/0x13c
>    anx7625_work_func+0x124/0x438
>    process_one_work+0x214/0x648
>    worker_thread+0x1b4/0x358
>    kthread+0x14c/0x214
>    ret_from_fork+0x10/0x20
>   Code: 910003fd a90153f3 aa0003f3 2a0103f4 (f9431400)
> 
> Fixes: f81455b2d332 ("drm: bridge: anx7625: implement minimal Type-C support")
> Reported-by: Salendarsingh Gaud <sgaud@qti.qualcomm.com>
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> [db: dropped chunk anx7625_typec_unregister(), wrote commit message]
> Cc: Amit Kucheria <akucheri@qti.qualcomm.com>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>   drivers/gpu/drm/bridge/analogix/anx7625.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index c43519097a45..7f943b6548f3 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1567,6 +1567,9 @@ static void anx7625_typec_set_status(struct anx7625_data *ctx,
>   				     unsigned int intr_status,
>   				     unsigned int intr_vector)
>   {
> +	if (!ctx->typec_port)
> +		return;
> +
>   	if (intr_vector & CC_STATUS)
>   		anx7625_typec_set_orientation(ctx);
>   	if (intr_vector & DATA_ROLE_STATUS) {
> 
> ---
> base-commit: 400a84e1f7a3681ef24d58d49b5d07e81c14f4e9
> change-id: 20260215-anx-fix-no-typec-4437cb7e54d2
> 
> Best regards,

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil