Skip to contentSkip to conversation

usb: typec: ucsi: debugfs: Fix GET commands on UCSI < 2.0

PATCH In review Ali Ahmet Memiş 3 participants 3 messages Oct 24 – Oct 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: ucsi: debugfs: Fix GET commands on UCSI < 2.0

Since the debugfs response buffer grew to 24 bytes, every GET command fails with -EINVAL on UCSI < 2.0, where the data length is limited to 16 bytes. Clamp the length to UCSI_MAX_DATA_LENGTH().

Fixes d9dc19910321 ("usb: typec: ucsi: Fix debugfs response truncation beyond 16 bytes")
---
 drivers/usb/typec/ucsi/debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/debugfs.c +2 -1
index 77a0dd75edd3..3cffd3778c67 100644
@@ -60,7 +60,8 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_GET_LPM_PPM_INFO:
 		ret = ucsi_send_command(ucsi, val,
 					&ucsi->debugfs->response,
-					sizeof(ucsi->debugfs->response));
+					min(sizeof(ucsi->debugfs->response),
+					    UCSI_MAX_DATA_LENGTH(ucsi)));
 		break;
 	default:
 		ret = -EOPNOTSUPP;
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

Since the debugfs response buffer grew to 24 bytes, every GET command fails with -EINVAL on UCSI < 2.0, where the data length is limited to 16 bytes. Clamp the length to UCSI_MAX_DATA_LENGTH().

Fixes d9dc19910321 ("usb: typec: ucsi: Fix debugfs response truncation beyond 16 bytes")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Ali Ahmet Memiş
Quoted 6 lines · Ali Ahmet Memiş

Since the debugfs response buffer grew to 24 bytes, every GET command fails with -EINVAL on UCSI < 2.0, where the data length is limited to 16 bytes. Clamp the length to UCSI_MAX_DATA_LENGTH().

Fixes d9dc19910321 ("usb: typec: ucsi: Fix debugfs response truncation beyond 16 bytes")
Quoted 20 lines
---
 drivers/usb/typec/ucsi/debugfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/debugfs.c +2 -1
index 77a0dd75edd3..3cffd3778c67 100644
@@ -60,7 +60,8 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_GET_LPM_PPM_INFO:
 		ret = ucsi_send_command(ucsi, val,
 					&ucsi->debugfs->response,
-					sizeof(ucsi->debugfs->response));
+					min(sizeof(ucsi->debugfs->response),
+					    UCSI_MAX_DATA_LENGTH(ucsi)));
 		break;
 	default:
 		ret = -EOPNOTSUPP;
Signature · 1 line
2.55.0
Signature · 1 line
heikki