Skip to content

Commit a99548b

Browse files
Bartosz GolaszewskiJiri Kosina
authored andcommitted
HID: cp2112: destroy mutex on driver detach
Use the devres variant of mutex_init() in order to free resources allocated with mutex debugging enabled. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 5e06802 commit a99548b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/hid/hid-cp2112.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/hidraw.h>
2323
#include <linux/i2c.h>
2424
#include <linux/module.h>
25+
#include <linux/mutex.h>
2526
#include <linux/nls.h>
2627
#include <linux/string_choices.h>
2728
#include <linux/usb/ch9.h>
@@ -1205,7 +1206,11 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
12051206
if (!dev->in_out_buffer)
12061207
return -ENOMEM;
12071208

1208-
mutex_init(&dev->lock);
1209+
ret = devm_mutex_init(&hdev->dev, &dev->lock);
1210+
if (ret) {
1211+
hid_err(hdev, "mutex init failed\n");
1212+
return ret;
1213+
}
12091214

12101215
ret = hid_parse(hdev);
12111216
if (ret) {

0 commit comments

Comments
 (0)