Skip to contentSkip to conversation

ipm: fix mutex use

PATCH In review Tomas Henzl 2 participants 2 messages May 14, 2010 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipm: fix mutex use

It looks like there is an unbalance with the mutexes after the latest IPMI patchset applied. For example in
"static __devinit int init_ipmi_si(void)"
....

	list_for_each_entry(e, &smi_infos, link) {
		if (!e->irq && (!type || e->addr_source == type)) {
			if (!try_smi_init(e)) {
				type = e->addr_source;
			}
		}
	}
	mutex_unlock(&smi_infos_lock);

we are calling mutex_unlock twice, because the mutex_unlock(&smi_infos_lock) is also called from try_smi_init.

If the lock in try_smi_init is not needed this can be then solved by removing the mutex_unlock(&smi_infos_lock) from try_smi_init.

---

drivers/char/ipmi/ipmi_si_intf.c +0 -4
index 8d7b879..c6af8e0 100644
@@ -3060,8 +3060,6 @@ static int try_smi_init(struct smi_info *new_smi)
 		goto out_err_stop_timer;
 	}
 
-	mutex_unlock(&smi_infos_lock);
-
 	printk(KERN_INFO "IPMI %s interface initialized\n",
 	       si_to_str[new_smi->si_type]);
 
@@ -3111,8 +3109,6 @@ static int try_smi_init(struct smi_info *new_smi)
 		new_smi->dev_registered = 0;
 	}
 
-	mutex_unlock(&smi_infos_lock);
-
 	return rv;
 }
 
Acked-by on v1 1/1
#1 lore raw

Yes, you are correct, we need this patch.

Thanks.

Quoted 45 lines · Tomas Henzl

It looks like there is an unbalance with the mutexes after the latest IPMI patchset applied. For example in "static __devinit int init_ipmi_si(void)"
....

	list_for_each_entry(e, &smi_infos, link) {
		if (!e->irq && (!type || e->addr_source == type)) {
			if (!try_smi_init(e)) {
				type = e->addr_source;
			}
		}
	}
	mutex_unlock(&smi_infos_lock);

we are calling mutex_unlock twice, because the mutex_unlock(&smi_infos_lock) is also called from try_smi_init.

If the lock in try_smi_init is not needed this can be then solved by removing the mutex_unlock(&smi_infos_lock) from try_smi_init.

---

drivers/char/ipmi/ipmi_si_intf.c +0 -4
index 8d7b879..c6af8e0 100644
@@ -3060,8 +3060,6 @@ static int try_smi_init(struct smi_info *new_smi)
 		goto out_err_stop_timer;
 	}
 
-	mutex_unlock(&smi_infos_lock);
-
 	printk(KERN_INFO "IPMI %s interface initialized\n",
 	       si_to_str[new_smi->si_type]);
 
@@ -3111,8 +3109,6 @@ static int try_smi_init(struct smi_info *new_smi)
 		new_smi->dev_registered = 0;
 	}
 
-	mutex_unlock(&smi_infos_lock);
-
 	return rv;
 }