@@ -663,6 +663,11 @@ static int lm3532_parse_node(struct lm3532_data *priv)
return ret;
}
+static void lm3532_mutex_destroy(void *lock)
+{
+ mutex_destroy(lock);
+}
+
static int lm3532_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -693,6 +698,11 @@ static int lm3532_probe(struct i2c_client *client,
}
mutex_init(&drvdata->lock);
+ ret = devm_add_action_or_reset(&client->dev, lm3532_mutex_destroy,
+ &drvdata->lock);
+ if (ret)
+ return ret;
+
i2c_set_clientdata(client, drvdata);
ret = lm3532_parse_node(drvdata);
When non-devm resources are allocated they mustn't be followed by devm allocations, otherwise it will break the tear down ordering and might lead to crashes or other bugs during ->remove() stage. Fix this by wrapping mutex_destroy() call with devm_add_action_or_reset(). Fixes: bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver") Signed-off-by: Wang Yufen <wangyufen@huawei.com> Cc: Dan Murphy <dmurphy@ti.com> --- drivers/leds/leds-lm3532.c | 10 ++++++++++ 1 file changed, 10 insertions(+)