lkml.org 
[lkml]   [2022]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectatc260x has broken locking
Date
When looking at this functions I found the locking to be broken for the atomic 
case (comments stripped):

static void regmap_lock_mutex(void *__mutex)
{
struct mutex *mutex = __mutex;

if (system_state > SYSTEM_RUNNING && irqs_disabled())
mutex_trylock(mutex);
else
mutex_lock(mutex);
}

static void regmap_unlock_mutex(void *__mutex)
{
struct mutex *mutex = __mutex;

mutex_unlock(mutex);
}

When the mutex is already locked and the atomic context is hit then the lock
will not be acquired, this is never noticed, and it afterwards is unlocked
anyway.

The comment says this is inspired from i2c_in_atomic_xfer_mode() to detect the
atomic case, but the important caller __i2c_lock_bus_helper() actually does
check and pass on the return value of mutex_trylock(), which is missing here.

Greetings,

Eike
--
Rolf Eike Beer, emlix GmbH, https://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-02-23 12:09    [W:0.037 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site