Re: [PATCH] w1: keep balance of mutex locks and refcnts

2017-10-09 Thread Evgeniy Polyakov
Hi Alexey 07.10.2017, 20:59, "Alexey Khoroshilov" : > Is it possible to switch to a nested variant: > mutex_lock-atomic_inc-atomic_dec-mutex_unlock > or > atomic_inc-mutex_lock-mutex_unlock-atomic_dec > ? Yeah, you are right, it is a bit messy - we drop the lock while sleeping waiting for the bu

Re: [PATCH] w1: keep balance of mutex locks and refcnts

2017-10-07 Thread Alexey Khoroshilov
Hi Evgeniy, mutex_lock() and atomic_inc() are not nested currently: ret = mutex_lock_interruptible(&dev->bus_mutex); ... atomic_inc(THERM_REFCNT(family_data)); ... mutex_unlock(&dev->bus_mutex); ... atomic_dec(THERM_REFCNT(family_data)); As a result, error handling without return

Re: [PATCH] w1: keep balance of mutex locks and refcnts

2017-09-30 Thread Evgeniy Polyakov
Hi Alex 29.09.2017, 23:23, "Alexey Khoroshilov" : > 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 functi