Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742736

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

From Evgeniy Polyakov <zbr@ioremap.net>
Newsgroups linux.kernel
Subject Re: [PATCH] w1: keep balance of mutex locks and refcnts
Date 2017-10-01 08:00 +0200
Message-ID <uvFse-6vk-5@gated-at.bofh.it> (permalink)
References <uva53-2zJ-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Alex

29.09.2017, 23:23, "Alexey Khoroshilov" <khoroshilov@ispras.ru>:
> 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).

Yes, this looks like a bug, thanks for finding it!

Please update your patch to use single exit point and not a mix of returns in the body of the function.

>          ret = mutex_lock_interruptible(&dev->bus_mutex);
>          if (ret != 0)
> - goto post_unlock;
> + return ret;
>
>          if (!sl->family_data) {
> - ret = -ENODEV;
> - goto pre_unlock;
> + mutex_unlock(&dev->bus_mutex);
> + return -ENODEV;
>          }

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] w1: keep balance of mutex locks and refcnts Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-09-29 22:30 +0200
  Re: [PATCH] w1: keep balance of mutex locks and refcnts Evgeniy Polyakov <zbr@ioremap.net> - 2017-10-01 08:00 +0200

csiph-web