Skip to content

Commit 45c7bda

Browse files
neosys007vinodkoul
authored andcommitted
soundwire: validate DT compatible before parsing it
`sdw_of_find_slaves()` fetches raw `"compatible"` bytes with `of_get_property()` and then immediately parses them with `sscanf("sdw%01x%04hx%04hx%02hhx", ...)`. Live-tree OF properties are stored as raw bytes plus a separate length; they are not globally guaranteed to be NUL-terminated. Validate the first compatible string before parsing it. Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Link: https://patch.msgid.link/20260403183504.4-soundwire-compatible-pengpeng@iscas.ac.cn Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent be6d8da commit 45c7bda

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/soundwire/slave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ int sdw_of_find_slaves(struct sdw_bus *bus)
244244
struct sdw_slave_id id;
245245
const __be32 *addr;
246246

247-
compat = of_get_property(node, "compatible", NULL);
248-
if (!compat)
247+
ret = of_property_read_string(node, "compatible", &compat);
248+
if (ret)
249249
continue;
250250

251251
ret = sscanf(compat, "sdw%01x%04hx%04hx%02hhx", &sdw_version,

0 commit comments

Comments
 (0)