From da72df9ab6872a02a8cbb66ffc342c16cf4d881c Mon Sep 17 00:00:00 2001 From: Matteo Golin Date: Thu, 24 Jul 2025 15:33:27 -0400 Subject: [PATCH] drivers/sensors/l86xxx: Fix kernel crashes on failed registration Sometimes this driver will boot when the serial port is of the wrong baud rate, and it cannot set the correct baud rate or verify communication. This commit prevents registration if any settings fail to be set, and also prevents the kernel thread from setting the L86 to enabled (this is done only by the uORB upper half). Signed-off-by: Matteo Golin --- drivers/sensors/l86xxx_uorb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/sensors/l86xxx_uorb.c b/drivers/sensors/l86xxx_uorb.c index be8ad4521f0..e07d19758a9 100644 --- a/drivers/sensors/l86xxx_uorb.c +++ b/drivers/sensors/l86xxx_uorb.c @@ -548,7 +548,6 @@ static int l86xxx_thread(int argc, FAR char *argv[]) (FAR l86xxx_dev_s *)((uintptr_t)strtoul(argv[1], NULL, 16)); struct sensor_gnss gps; memset(&gps, 0, sizeof(gps)); - dev->enabled = true; int err; int bw; @@ -792,6 +791,7 @@ int l86xxx_register(FAR const char *uartpath, int devno) if (err < 0) { snwarn("Couldn't set baud rate of device: %d\n", err); + goto close_file; } #endif @@ -799,6 +799,7 @@ int l86xxx_register(FAR const char *uartpath, int devno) if (err < 0) { snwarn("Couldn't set position fix interval, %d\n", err); + goto close_file; } /* Register UORB Sensor */