Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: ps2-gpio - use guard notation when acquiring mutex

Using guard notation makes the code more compact and error handling
more robust by ensuring that mutexes are released in all code paths
when control leaves critical section.

Link: https://lore.kernel.org/r/20240905041732.2034348-15-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+2 -2
+2 -2
drivers/input/serio/ps2-gpio.c
··· 133 133 int ret = 0; 134 134 135 135 if (in_task()) { 136 - mutex_lock(&drvdata->tx.mutex); 136 + guard(mutex)(&drvdata->tx.mutex); 137 + 137 138 __ps2_gpio_write(serio, val); 138 139 if (!wait_for_completion_timeout(&drvdata->tx.complete, 139 140 msecs_to_jiffies(10000))) 140 141 ret = SERIO_TIMEOUT; 141 - mutex_unlock(&drvdata->tx.mutex); 142 142 } else { 143 143 __ps2_gpio_write(serio, val); 144 144 }