Commit-ID: 5fde3b94abe06ea921e72d9f44dc2b78f88cf2c2 Gitweb: http://git.kernel.org/tip/5fde3b94abe06ea921e72d9f44dc2b78f88cf2c2 Author: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> AuthorDate: Mon, 12 Dec 2011 15:15:54 +0800 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Mon, 12 Dec 2011 23:35:36 +0200 kvm tools: protect shared global id in compat_mtx C.S. The global id is shared, protect it when access it. Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/guest_compat.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/kvm/guest_compat.c b/tools/kvm/guest_compat.c index de97df5..8dd451b 100644 --- a/tools/kvm/guest_compat.c +++ b/tools/kvm/guest_compat.c @@ -20,6 +20,7 @@ static LIST_HEAD(messages); int compat__add_message(const char *title, const char *desc) { struct compat_message *msg; + int msg_id; msg = malloc(sizeof(*msg)); if (msg == NULL) @@ -33,12 +34,12 @@ int compat__add_message(const char *title, const char *desc) mutex_lock(&compat_mtx); - msg->id = id; + msg->id = msg_id = id++; list_add_tail(&msg->list, &messages); mutex_unlock(&compat_mtx); - return id++; + return msg_id; cleanup: if (msg) { -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html