drivers: susbsys: Check errors on devices selected using dt macro
Some Kconfig defined devices may be defined using dt_chosen_label function. Since there is no way to ensure a device enabled in dts is also defined in Kconfig, it may happen that instance is not actually defined. In this case device_get_binding might return 0, leading to undefined behavior in the function that calls it. When not already done, systematically check return of function device_get_binding on devices defined through dt_chosen_label macro. Trigger ASSERT when required and return error when possible. Fixes #20068 Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
8fbc83c651
commit
2716cbcaa6
3 changed files with 9 additions and 0 deletions
|
@ -274,6 +274,10 @@ static int enable_shell_uart(struct device *arg)
|
|||
(CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > LOG_LEVEL_DBG) ?
|
||||
CONFIG_LOG_MAX_LEVEL : CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL;
|
||||
|
||||
if (dev == NULL) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
shell_init(&shell_uart, dev, true, log_backend, level);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue