From e7cc62a9c8f1ea3301e741d0bb56fad633901e3e Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Tue, 1 Feb 2022 15:25:45 +0300 Subject: [PATCH] sinowealth: return an error code instead of doing an assert While I doubt it will actually ever get hit, there is no reason to crash the whole daemon because of this. --- src/driver-sinowealth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/driver-sinowealth.c b/src/driver-sinowealth.c index adf69f02..cea8b3e9 100644 --- a/src/driver-sinowealth.c +++ b/src/driver-sinowealth.c @@ -524,7 +524,10 @@ sinowealth_get_active_profile(struct ratbag_device *device) static int sinowealth_set_active_profile(struct ratbag_device *device, unsigned int index) { - assert(index <= SINOWEALTH_NUM_PROFILES - 1); + if (index >= SINOWEALTH_NUM_PROFILES) { + log_error(device->ratbag, "Profile index %u is out of range", index); + return -EINVAL; + } int rc = 0;