input: psmouse: Add unlock mutex before to exit psmouse_attr_set_protocol
Subsystems (2)
PATCH 1/1 input: psmouse: Add unlock mutex before to exit psmouse_attr_set_protocol
In error handling code for "no such device" or memory already used, release the mutex before to return.
Found with Coccinelle static analisys tool,
script: https://coccinelle.gitlabpages.inria.fr/website/rules/mut.cocci
--- drivers/input/mouse/psmouse-base.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/mouse/psmouse-base.c +2 -0
@@ -1930,11 +1930,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, coif (serio->drv != &psmouse_drv) {input_free_device (new_dev); +mutex_unlock (&psmouse_mutex);return -ENODEV ; }if (psmouse->protocol == proto) {input_free_device (new_dev); +mutex_unlock (&psmouse_mutex);return count;/* switched by other thread */ } }
Signature · 1 line
2.43.0
Dmitry Torokhov
maintainerHi Alessandro,
Quoted 16 lines · Alessandro Zanni
In error handling code for "no such device" or memory already used, release the mutex before to return.
Found with Coccinelle static analisys tool,
script: https://coccinelle.gitlabpages.inria.fr/website/rules/mut.cocciSigned-off-by Alessandro Zanni <[email protected]>--- drivers/input/mouse/psmouse-base.c | 2 ++ 1 file changed, 2 insertions(+)drivers/input/mouse/psmouse-base.c +0
-0
drivers/input/mouse/psmouse-base.c static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co · line 1933
Quoted 4 lines
drivers/input/mouse/psmouse-base.c +1
-0@@ -1930,11 +1930,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, coif (serio->drv != &psmouse_drv) {input_free_device (new_dev); +mutex_unlock (&psmouse_mutex);
I am sorry, bit this makes absolutely no sense. This mutex is taken (and then released) in psmouse_attr_set_helper() wrapper. psmouse_attr_set_protocol() momentarily drops and then reacquires it, but it should not release it either failure or success parts.
Thanks.
Signature · 1 line
Dmitry