Skip to content

Commit 4f1885a

Browse files
frextritecminyard
authored andcommitted
drivers: char: ipmi: ipmi_msghandler: Pass lockdep expression to RCU lists
intf->cmd_rcvrs is traversed with list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of intf->cmd_rcvrs_mutex. ipmi_interfaces is traversed using list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of ipmi_interfaces_mutex. Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists. Add macro for the corresponding lockdep expression to make the code clean and concise. Signed-off-by: Amol Grover <[email protected]> Message-Id: <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Tested-by: John Garry <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent 3cc6e2c commit 4f1885a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ static DEFINE_MUTEX(ipmidriver_mutex);
618618

619619
static LIST_HEAD(ipmi_interfaces);
620620
static DEFINE_MUTEX(ipmi_interfaces_mutex);
621+
#define ipmi_interfaces_mutex_held() \
622+
lockdep_is_held(&ipmi_interfaces_mutex)
621623
static struct srcu_struct ipmi_interfaces_srcu;
622624

623625
/*
@@ -1321,7 +1323,8 @@ static void _ipmi_destroy_user(struct ipmi_user *user)
13211323
* synchronize_srcu()) then free everything in that list.
13221324
*/
13231325
mutex_lock(&intf->cmd_rcvrs_mutex);
1324-
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) {
1326+
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link,
1327+
lockdep_is_held(&intf->cmd_rcvrs_mutex)) {
13251328
if (rcvr->user == user) {
13261329
list_del_rcu(&rcvr->link);
13271330
rcvr->next = rcvrs;
@@ -1599,7 +1602,8 @@ static struct cmd_rcvr *find_cmd_rcvr(struct ipmi_smi *intf,
15991602
{
16001603
struct cmd_rcvr *rcvr;
16011604

1602-
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) {
1605+
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link,
1606+
lockdep_is_held(&intf->cmd_rcvrs_mutex)) {
16031607
if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)
16041608
&& (rcvr->chans & (1 << chan)))
16051609
return rcvr;
@@ -1614,7 +1618,8 @@ static int is_cmd_rcvr_exclusive(struct ipmi_smi *intf,
16141618
{
16151619
struct cmd_rcvr *rcvr;
16161620

1617-
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) {
1621+
list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link,
1622+
lockdep_is_held(&intf->cmd_rcvrs_mutex)) {
16181623
if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)
16191624
&& (rcvr->chans & chans))
16201625
return 0;
@@ -3450,7 +3455,8 @@ int ipmi_add_smi(struct module *owner,
34503455
/* Look for a hole in the numbers. */
34513456
i = 0;
34523457
link = &ipmi_interfaces;
3453-
list_for_each_entry_rcu(tintf, &ipmi_interfaces, link) {
3458+
list_for_each_entry_rcu(tintf, &ipmi_interfaces, link,
3459+
ipmi_interfaces_mutex_held()) {
34543460
if (tintf->intf_num != i) {
34553461
link = &tintf->link;
34563462
break;

0 commit comments

Comments
 (0)