File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -150,9 +150,15 @@ static void hlist_add_ucounts(struct ucounts *ucounts)
150
150
spin_unlock_irq (& ucounts_lock );
151
151
}
152
152
153
+ static inline bool get_ucounts_or_wrap (struct ucounts * ucounts )
154
+ {
155
+ /* Returns true on a successful get, false if the count wraps. */
156
+ return !atomic_add_negative (1 , & ucounts -> count );
157
+ }
158
+
153
159
struct ucounts * get_ucounts (struct ucounts * ucounts )
154
160
{
155
- if (atomic_add_negative ( 1 , & ucounts -> count )) {
161
+ if (! get_ucounts_or_wrap ( ucounts )) {
156
162
put_ucounts (ucounts );
157
163
ucounts = NULL ;
158
164
}
@@ -163,7 +169,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
163
169
{
164
170
struct hlist_head * hashent = ucounts_hashentry (ns , uid );
165
171
struct ucounts * ucounts , * new ;
166
- long overflow ;
172
+ bool wrapped ;
167
173
168
174
spin_lock_irq (& ucounts_lock );
169
175
ucounts = find_ucounts (ns , uid , hashent );
@@ -188,9 +194,9 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
188
194
return new ;
189
195
}
190
196
}
191
- overflow = atomic_add_negative ( 1 , & ucounts -> count );
197
+ wrapped = ! get_ucounts_or_wrap ( ucounts );
192
198
spin_unlock_irq (& ucounts_lock );
193
- if (overflow ) {
199
+ if (wrapped ) {
194
200
put_ucounts (ucounts );
195
201
return NULL ;
196
202
}
You can’t perform that action at this time.
0 commit comments