lkml.org 
[lkml]   [2021]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC 1/2] i2c: designware: Add missing locks
czw., 23 gru 2021 o 16:51 Andy Shevchenko
<andriy.shevchenko@linux.intel.com> napisał(a):
>
> On Wed, Dec 22, 2021 at 10:45:57AM +0100, Jan Dabros wrote:
> > All accesses to controller's registers should be protected on
> > probe, disable and xfer paths. This is needed for i2c bus controllers
> > that are shared with but not controlled by kernel.
>
> ...
>
> > + ret = i2c_dw_acquire_lock(dev);
> > + if (ret)
> > + return ret;
> > +
> > ret = regmap_read(dev->map, DW_IC_COMP_PARAM_1, &param);
> > if (ret)
> > return ret;
> > + i2c_dw_release_lock(dev);
>
> Not sure this part is fully correct. Please, fix the leakage.

Correct, I will move release() right below regmap_read() call, before
checking return code.

>
> ...
>
> > + ret = i2c_dw_acquire_lock(dev);
> > + if (ret)
> > + return;
> >
> > /* Disable controller */
> > __i2c_dw_disable(dev);
> > @@ -614,6 +624,8 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
> > /* Disable all interrupts */
> > regmap_write(dev->map, DW_IC_INTR_MASK, 0);
> > regmap_read(dev->map, DW_IC_CLR_INTR, &dummy);
>
> > + i2c_dw_release_lock(dev);
>
> Not enough context here, bu I believe there is the same issue(s).

Since we are ignoring values returned by regmap_write()/read() and
also __i2c_dw_disable() returns void I don't see a leakage here. Don't
have more function calls here.

\
 
 \ /
  Last update: 2021-12-27 08:18    [W:0.074 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site