summaryrefslogtreecommitdiff
path: root/include/linux/refcount_types.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-12-11 15:15:38 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-12-20 19:26:31 -0500
commitf9d6966b7f4182f612208f9dad9e2cfaaf667ba3 (patch)
treed33c7d6d74661490e84970d68957fc7f804a3bcf /include/linux/refcount_types.h
parent1ef83969bb12e594fe44ceba406095e80a824c91 (diff)
refcount: Split out refcount_types.h
More trimming of sched.h dependencies. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/refcount_types.h')
-rw-r--r--include/linux/refcount_types.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/refcount_types.h b/include/linux/refcount_types.h
new file mode 100644
index 000000000000..162004f06edf
--- /dev/null
+++ b/include/linux/refcount_types.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_REFCOUNT_TYPES_H
+#define _LINUX_REFCOUNT_TYPES_H
+
+#include <linux/types.h>
+
+/**
+ * typedef refcount_t - variant of atomic_t specialized for reference counts
+ * @refs: atomic_t counter field
+ *
+ * The counter saturates at REFCOUNT_SATURATED and will not move once
+ * there. This avoids wrapping the counter and causing 'spurious'
+ * use-after-free bugs.
+ */
+typedef struct refcount_struct {
+ atomic_t refs;
+} refcount_t;
+
+#endif /* _LINUX_REFCOUNT_TYPES_H */