[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-7100810a75b9854f1b05550b54500497c5914d4b@git.kernel.org>
Date: Mon, 6 Mar 2017 23:45:16 -0800
From: tip-bot for Elena Reshetova <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: keescook@...omium.org, dwindsor@...il.com, acme@...hat.com,
akpm@...ux-foundation.org, gregkh@...uxfoundation.org,
tglx@...utronix.de, matija.glavinic-pecotic.ext@...ia.com,
ishkamiel@...il.com, jolsa@...nel.org, elena.reshetova@...el.com,
hpa@...or.com, alexander.shishkin@...ux.intel.com,
peterz@...radead.org, mingo@...nel.org,
linux-kernel@...r.kernel.org, mark.rutland@....com
Subject: [tip:perf/core] perf dso: Convert dso.refcnt from atomic_t to
refcount_t
Commit-ID: 7100810a75b9854f1b05550b54500497c5914d4b
Gitweb: http://git.kernel.org/tip/7100810a75b9854f1b05550b54500497c5914d4b
Author: Elena Reshetova <elena.reshetova@...el.com>
AuthorDate: Tue, 21 Feb 2017 17:34:58 +0200
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 3 Mar 2017 19:07:15 -0300
perf dso: Convert dso.refcnt from atomic_t to refcount_t
The refcount_t type and corresponding API should be used instead of atomic_t
when the variable is used as a reference counter.
This allows to avoid accidental refcounter overflows that might lead to
use-after-free situations.
Signed-off-by: Elena Reshetova <elena.reshetova@...el.com>
Signed-off-by: David Windsor <dwindsor@...il.com>
Signed-off-by: Hans Liljestrand <ishkamiel@...il.com>
Signed-off-by: Kees Kook <keescook@...omium.org>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: David Windsor <dwindsor@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Hans Liljestrand <ishkamiel@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Kees Kook <keescook@...omium.org>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@...ia.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: alsa-devel@...a-project.org
Link: http://lkml.kernel.org/r/1487691303-31858-5-git-send-email-elena.reshetova@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/dso.c | 6 +++---
tools/perf/util/dso.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index d38b62a..42db00d 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1109,7 +1109,7 @@ struct dso *dso__new(const char *name)
INIT_LIST_HEAD(&dso->node);
INIT_LIST_HEAD(&dso->data.open_entry);
pthread_mutex_init(&dso->lock, NULL);
- atomic_set(&dso->refcnt, 1);
+ refcount_set(&dso->refcnt, 1);
}
return dso;
@@ -1147,13 +1147,13 @@ void dso__delete(struct dso *dso)
struct dso *dso__get(struct dso *dso)
{
if (dso)
- atomic_inc(&dso->refcnt);
+ refcount_inc(&dso->refcnt);
return dso;
}
void dso__put(struct dso *dso)
{
- if (dso && atomic_dec_and_test(&dso->refcnt))
+ if (dso && refcount_dec_and_test(&dso->refcnt))
dso__delete(dso);
}
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ecc4bbd..12350b1 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -1,7 +1,7 @@
#ifndef __PERF_DSO
#define __PERF_DSO
-#include <linux/atomic.h>
+#include <linux/refcount.h>
#include <linux/types.h>
#include <linux/rbtree.h>
#include <sys/types.h>
@@ -187,7 +187,7 @@ struct dso {
void *priv;
u64 db_id;
};
- atomic_t refcnt;
+ refcount_t refcnt;
char name[0];
};
Powered by blists - more mailing lists