Skip to content

Commit 0bb0077

Browse files
authored
Fix a crash when initializing an illuminance sensor on Linux (#17408)
1 parent 47d8883 commit 0bb0077

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

input/common/linux_common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate)
201201
if (!sensor)
202202
goto error;
203203

204+
device = retro_opendir(IIO_DEVICES_DIR);
205+
if (!device)
206+
goto error;
207+
204208
sensor->millilux = 0;
205209
sensor->poll_rate = rate ? rate : DEFAULT_POLL_RATE;
206210
sensor->thread = NULL; /* We'll spawn a thread later, once we find a sensor */
@@ -243,7 +247,7 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate)
243247
}
244248

245249
error:
246-
RARCH_ERR("Failed to find an illuminance sensor\n");
250+
RARCH_ERR("Failed to find an illuminance sensor in " IIO_DEVICES_DIR "\n");
247251
retro_closedir(device);
248252

249253
free(sensor);

0 commit comments

Comments
 (0)