Skip to content

Commit 98aeb2c

Browse files
committed
zephyr: Avoid crash on gc collect if zephyr_device_find() fails.
Signed-off-by: Daniel Campora <[email protected]>
1 parent 9fd6a28 commit 98aeb2c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ports/zephyr/machine_uart.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
163163
static mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
164164
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
165165

166+
const struct device *dev = zephyr_device_find(args[0]);
166167
machine_uart_obj_t *self = mp_obj_malloc_with_finaliser(machine_uart_obj_t, &machine_uart_type);
167-
self->dev = zephyr_device_find(args[0]);
168+
self->dev = dev;
168169
self->tx_complete = true;
169170

170171
mp_map_t kw_args;

0 commit comments

Comments
 (0)