Skip to contentSkip to conversation

platform/chrome: cros_ec_typec: Init mutex in Thunderbolt registration

PATCH In review Tzung-Bi Shih 3 participants 4 messages May 5 – May 6

Subsystems (4)
lore
Share & tools
lore

Tzung-Bi Shih

author maintainer
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_typec: Init mutex in Thunderbolt registration

cros_typec_register_thunderbolt() missed initializing the adata->lock mutex. This leads to a NULL dereference when the mutex is later acquired (e.g. in cros_typec_altmode_work()).

Initialize the mutex in cros_typec_register_thunderbolt() to fix the issue.

Fixes 3b00be26b16a ("platform/chrome: cros_ec_typec: Thunderbolt support")
---
 drivers/platform/chrome/cros_typec_altmode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_typec_altmode.c +1 -0
index 557340b53af0..66c546bf89b5 100644
@@ -359,6 +359,7 @@ cros_typec_register_thunderbolt(struct cros_typec_port *port,
 	}
 
 	INIT_WORK(&adata->work, cros_typec_altmode_work);
+	mutex_init(&adata->lock);
 	adata->alt = alt;
 	adata->port = port;
 	adata->ap_mode_entry = true;
Signature · 1 line
2.54.0.545.g6539524ca2-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Tzung-Bi Shih

cros_typec_register_thunderbolt() missed initializing the adata->lock mutex. This leads to a NULL dereference when the mutex is later acquired (e.g. in cros_typec_altmode_work()).

Initialize the mutex in cros_typec_register_thunderbolt() to fix the issue.

Fixes 3b00be26b16a ("platform/chrome: cros_ec_typec: Thunderbolt support")
---
 drivers/platform/chrome/cros_typec_altmode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_typec_altmode.c +1 -1
index 557340b53af0..66c546bf89b5 100644
@@ -359,6 +359,7 @@ cros_typec_register_thunderbolt(struct cros_typec_port *port,
        }
 
        INIT_WORK(&adata->work, cros_typec_altmode_work);
+       mutex_init(&adata->lock);
        adata->alt = alt;
        adata->port = port;
        adata->ap_mode_entry = true;
--
Quoted 2 lines

2.54.0.545.g6539524ca2-goog

Thanks for the fix.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Tzung-Bi Shih
Quoted 10 lines · Tzung-Bi Shih

cros_typec_register_thunderbolt() missed initializing the adata->lock mutex. This leads to a NULL dereference when the mutex is later acquired (e.g. in cros_typec_altmode_work()).

Initialize the mutex in cros_typec_register_thunderbolt() to fix the issue.

Fixes 3b00be26b16a ("platform/chrome: cros_ec_typec: Thunderbolt support")

Thanks for the fix!

Quoted 19 lines
---
 drivers/platform/chrome/cros_typec_altmode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_typec_altmode.c +1 -0
index 557340b53af0..66c546bf89b5 100644
@@ -359,6 +359,7 @@ cros_typec_register_thunderbolt(struct cros_typec_port *port,
 	}
 
 	INIT_WORK(&adata->work, cros_typec_altmode_work);
+	mutex_init(&adata->lock);
 	adata->alt = alt;
 	adata->port = port;
 	adata->ap_mode_entry = true;
Signature · 1 line
2.54.0.545.g6539524ca2-goog
author maintainer
#3 lore raw
In reply to Tzung-Bi Shih
Quoted 8 lines · Tzung-Bi Shih

cros_typec_register_thunderbolt() missed initializing the adata->lock mutex. This leads to a NULL dereference when the mutex is later acquired (e.g. in cros_typec_altmode_work()).

Initialize the mutex in cros_typec_register_thunderbolt() to fix the issue.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-7.1

[1/1] platform/chrome: cros_ec_typec: Init mutex in Thunderbolt registration

      commit: 525cb7ba6661074c1c5cc3772bccc6afab6791ef

Thanks!