Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device: fix potential truncation of DT-derived device names #31556

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Jan 23, 2021

While using the encoded path to a device tree node guarantees a unique identifier for the corresponding device there is a limit on the number of characters of that name that can be captured when looking up a device by name from user mode, and the path can exceed that limit.

Synthesize a unique name from the node dependency ordinal instead, and update the gen_defines script to record the name associated with the full path in the extern declaration.

Add a build-time check that no device is created with a name that violates the user mode requirement.

Also update the ethernet device DTS helper function to use the same inference for dev_name and label that the real one does, since it bypasses the real one.

@pabigot pabigot added Blocked Blocked by another PR or issue DNM This PR should not be merged (Do Not Merge) labels Jan 23, 2021
@pabigot pabigot added this to the v2.5.0 milestone Jan 23, 2021
@pabigot pabigot requested review from nashif and galak January 23, 2021 14:00
@github-actions github-actions bot added area: API Changes to public APIs area: Devicetree Tooling PR modifies or adds a Device Tree tooling area: Documentation area: Kernel area: Shell Shell subsystem area: Tests Issues related to a particular existing or missing test labels Jan 23, 2021
While using the encoded path to a device tree node guarantees a unique
identifier for the corresponding device there is a limit on the number
of characters of that name that can be captured when looking up a
device by name from user mode, and the path can exceed that limit.

Synthesize a unique name from the node dependency ordinal instead, and
update the gen_defines script to record the name associated with the
full path in the extern declaration.

Add a build-time check that no device is created with a name that
violates the user mode requirement.

Also update the network device DTS helper functions to use the same
inference for dev_name and label that the real one does, since they
bypass the real one.

Signed-off-by: Peter Bigot <[email protected]>
@pabigot pabigot removed Blocked Blocked by another PR or issue DNM This PR should not be merged (Do Not Merge) labels Jan 24, 2021
@nashif nashif merged commit f91e9fb into zephyrproject-rtos:master Jan 25, 2021
@pabigot pabigot deleted the nordic/20210123a branch January 28, 2021 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Devicetree Tooling PR modifies or adds a Device Tree tooling area: Documentation area: Kernel area: Networking area: Shell Shell subsystem area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants