aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-01 03:25:55 -0500
committerIngo Molnar <mingo@kernel.org>2017-03-01 03:25:55 -0500
commit9dcfe2c75b51f454f39c2de4756e841228865b47 (patch)
tree994ed0f8e86d8eeb6baec7a72b489fef5cd8f9be
parent2d6be4abf514fc26c83d239c7f31da1f95e4a31d (diff)
locking/refcounts: Change WARN() to WARN_ONCE()
Linus noticed that the new refcount.h APIs used WARN(), which would turn into a dmesg DoS if it triggers frequently on some buggy driver. So make sure we only warn once. These warnings are never supposed to happen, so it's typically not a problem to lose subsequent warnings. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Elena Reshetova <elena.reshetova@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/CA+55aFzbYUTZ=oqZ2YgDjY0C2_n6ODhTfqj6V+m5xWmDxsuB0w@mail.gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--lib/refcount.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/refcount.c b/lib/refcount.c
index 1d33366189d1..aa09ad3c30b0 100644
--- a/lib/refcount.c
+++ b/lib/refcount.c
@@ -58,7 +58,7 @@ bool refcount_add_not_zero(unsigned int i, refcount_t *r)
58 val = old; 58 val = old;
59 } 59 }
60 60
61 WARN(new == UINT_MAX, "refcount_t: saturated; leaking memory.\n"); 61 WARN_ONCE(new == UINT_MAX, "refcount_t: saturated; leaking memory.\n");
62 62
63 return true; 63 return true;
64} 64}
@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(refcount_add_not_zero);
66 66
67void refcount_add(unsigned int i, refcount_t *r) 67void refcount_add(unsigned int i, refcount_t *r)
68{ 68{
69 WARN(!refcount_add_not_zero(i, r), "refcount_t: addition on 0; use-after-free.\n"); 69 WARN_ONCE(!refcount_add_not_zero(i, r), "refcount_t: addition on 0; use-after-free.\n");
70} 70}
71EXPORT_SYMBOL_GPL(refcount_add); 71EXPORT_SYMBOL_GPL(refcount_add);
72 72
@@ -97,7 +97,7 @@ bool refcount_inc_not_zero(refcount_t *r)
97 val = old; 97 val = old;
98 } 98 }
99 99
100 WARN(new == UINT_MAX, "refcount_t: saturated; leaking memory.\n"); 100 WARN_ONCE(new == UINT_MAX, "refcount_t: saturated; leaking memory.\n");
101 101
102 return true; 102 return true;
103} 103}
@@ -111,7 +111,7 @@ EXPORT_SYMBOL_GPL(refcount_inc_not_zero);
111 */ 111 */
112void refcount_inc(refcount_t *r) 112void refcount_inc(refcount_t *r)
113{ 113{
114 WARN(!refcount_inc_not_zero(r), "refcount_t: increment on 0; use-after-free.\n"); 114 WARN_ONCE(!refcount_inc_not_zero(r), "refcount_t: increment on 0; use-after-free.\n");
115} 115}
116EXPORT_SYMBOL_GPL(refcount_inc); 116EXPORT_SYMBOL_GPL(refcount_inc);
117 117
@@ -125,7 +125,7 @@ bool refcount_sub_and_test(unsigned int i, refcount_t *r)
125 125
126 new = val - i; 126 new = val - i;
127 if (new > val) { 127 if (new > val) {
128 WARN(new > val, "refcount_t: underflow; use-after-free.\n"); 128 WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
129 return false; 129 return false;
130 } 130 }
131 131
@@ -164,7 +164,7 @@ EXPORT_SYMBOL_GPL(refcount_dec_and_test);
164 164
165void refcount_dec(refcount_t *r) 165void refcount_dec(refcount_t *r)
166{ 166{
167 WARN(refcount_dec_and_test(r), "refcount_t: decrement hit 0; leaking memory.\n"); 167 WARN_ONCE(refcount_dec_and_test(r), "refcount_t: decrement hit 0; leaking memory.\n");
168} 168}
169EXPORT_SYMBOL_GPL(refcount_dec); 169EXPORT_SYMBOL_GPL(refcount_dec);
170 170
@@ -204,7 +204,7 @@ bool refcount_dec_not_one(refcount_t *r)
204 204
205 new = val - 1; 205 new = val - 1;
206 if (new > val) { 206 if (new > val) {
207 WARN(new > val, "refcount_t: underflow; use-after-free.\n"); 207 WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
208 return true; 208 return true;
209 } 209 }
210 210