w1: keep balance of mutex locks and refcnts
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Sat, 21 Oct 2017 22:03:44 +0000 (01:03 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Nov 2017 13:26:50 +0000 (14:26 +0100)
commitf53459c00871a7c3db5b69b49d840ca9d497a695
tree8681cb2fabc0ae2344c867c885dc55cdccd6696a
parentd4035a8c1ff7288af9e47d6d05384f14c9308ea1
w1: keep balance of mutex locks and refcnts

w1_therm_eeprom() and w1_DS18B20_precision() decrement THERM_REFCNT
on error paths, while they did not increment it yet.

read_therm() unlocks bus mutex on some error paths,
while it is not acquired.

The patch makes sure all the functions keep the balance in usage of
the mutex and the THERM_REFCNT.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/slaves/w1_therm.c