]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: lp8860: Check return value of devm_mutex_init()
authorThomas Weißschuh <linux@weissschuh.net>
Tue, 17 Jun 2025 17:08:13 +0000 (19:08 +0200)
committerBoqun Feng <boqun.feng@gmail.com>
Fri, 11 Jul 2025 22:11:19 +0000 (15:11 -0700)
devm_mutex_init() can fail. With CONFIG_DEBUG_MUTEXES=y the mutex will be
marked as unusable and trigger errors on usage.

Add the missed check.

Fixes: 87a59548af95 ("leds: lp8860: Use new mutex guards to cleanup function exits")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Andrew Davis <afd@ti.com>
Acked-by: Lee Jones <lee@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20250617-must_check-devm_mutex_init-v7-2-d9e449f4d224@weissschuh.net
drivers/leds/leds-lp8860.c

index 52b97c9f2a03567aa12d4f63a951593a5e7017d5..0962c00c215a11f555a7878a3b65824b5219a1fa 100644 (file)
@@ -307,7 +307,9 @@ static int lp8860_probe(struct i2c_client *client)
        led->client = client;
        led->led_dev.brightness_set_blocking = lp8860_brightness_set;
 
-       devm_mutex_init(&client->dev, &led->lock);
+       ret = devm_mutex_init(&client->dev, &led->lock);
+       if (ret)
+               return dev_err_probe(&client->dev, ret, "Failed to initialize lock\n");
 
        led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config);
        if (IS_ERR(led->regmap)) {