Skip to content

Commit df61590

Browse files
duda-patrykTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_proto: Lock device when updating MKBP version
The cros_ec_get_host_command_version_mask() function requires that the caller must have ec_dev->lock mutex before calling it. This requirement was not met and as a result it was possible that two commands were sent to the device at the same time. The problem was observed while using UART backend which doesn't use any additional locks, unlike SPI backend which locks the controller until response is received. Fixes: f74c755 ("platform/chrome: cros_ec_proto: Update version on GET_NEXT_EVENT failure") Cc: [email protected] Signed-off-by: Patryk Duda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 4baf1cc commit df61590

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,11 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev,
813813
if (ret == -ENOPROTOOPT) {
814814
dev_dbg(ec_dev->dev,
815815
"GET_NEXT_EVENT returned invalid version error.\n");
816+
mutex_lock(&ec_dev->lock);
816817
ret = cros_ec_get_host_command_version_mask(ec_dev,
817818
EC_CMD_GET_NEXT_EVENT,
818819
&ver_mask);
820+
mutex_unlock(&ec_dev->lock);
819821
if (ret < 0 || ver_mask == 0)
820822
/*
821823
* Do not change the MKBP supported version if we can't

0 commit comments

Comments
 (0)