Skip to content

Commit 7d94120

Browse files
committed
soundwire: stream: validate slave port properties
sdw_slave_port_config() validates that a port number is within the generic valid range, but does not verify that the Slave exposes the port for the requested stream direction. As a result, an in-range but unsupported port can be accepted. Use sdw_get_slave_dpn_prop() to perform the direction-specific lookup and reject unsupported ports before storing the runtime configuration. Signed-off-by: Eric Wu <kunjinkao.jp@gmail.com>
1 parent d075847 commit 7d94120

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

drivers/soundwire/stream.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,14 +1069,23 @@ static int sdw_slave_port_config(struct sdw_slave *slave,
10691069

10701070
i = 0;
10711071
list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
1072-
/*
1073-
* TODO: Check valid port range as defined by DisCo/
1074-
* slave
1075-
*/
10761072
if (!is_bpt_stream) {
10771073
ret = sdw_slave_port_is_valid_range(&slave->dev, port_config[i].num);
10781074
if (ret < 0)
10791075
return ret;
1076+
1077+
/*
1078+
* A port in the generic valid range may still be unsupported by
1079+
* the Slave or unavailable for the requested stream direction.
1080+
*/
1081+
if (!sdw_get_slave_dpn_prop(slave, s_rt->direction,
1082+
port_config[i].num)) {
1083+
dev_err(&slave->dev,
1084+
"port %u not supported for %s\n",
1085+
port_config[i].num,
1086+
s_rt->direction == SDW_DATA_DIR_TX ? "TX" : "RX");
1087+
return -EINVAL;
1088+
}
10801089
} else if (port_config[i].num) {
10811090
return -EINVAL;
10821091
}

0 commit comments

Comments
 (0)