]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
leds: an30259a: add a check for devm_regmap_init_i2c
authorChuhong Yuan <hslester96@gmail.com>
Wed, 16 Oct 2019 12:54:03 +0000 (20:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Jan 2020 18:17:03 +0000 (19:17 +0100)
[ Upstream commit fc7b5028f2627133c7c18734715a08829eab4d1f ]

an30259a_probe misses a check for devm_regmap_init_i2c and may cause
problems.
Add a check and print errors like other leds drivers.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/leds-an30259a.c

index 250dc9d6f63502d7145b0797f77780aadf04c87b..82350a28a56445468cb35d2b94e4be75bf7b0e25 100644 (file)
@@ -305,6 +305,13 @@ static int an30259a_probe(struct i2c_client *client)
 
        chip->regmap = devm_regmap_init_i2c(client, &an30259a_regmap_config);
 
+       if (IS_ERR(chip->regmap)) {
+               err = PTR_ERR(chip->regmap);
+               dev_err(&client->dev, "Failed to allocate register map: %d\n",
+                       err);
+               goto exit;
+       }
+
        for (i = 0; i < chip->num_leds; i++) {
                struct led_init_data init_data = {};