diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/res_counter.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h index c9d625ca659e..d06d014afda6 100644 --- a/include/linux/res_counter.h +++ b/include/linux/res_counter.h | |||
| @@ -142,7 +142,10 @@ static inline unsigned long long res_counter_margin(struct res_counter *cnt) | |||
| 142 | unsigned long flags; | 142 | unsigned long flags; |
| 143 | 143 | ||
| 144 | spin_lock_irqsave(&cnt->lock, flags); | 144 | spin_lock_irqsave(&cnt->lock, flags); |
| 145 | margin = cnt->limit - cnt->usage; | 145 | if (cnt->limit > cnt->usage) |
| 146 | margin = cnt->limit - cnt->usage; | ||
| 147 | else | ||
| 148 | margin = 0; | ||
| 146 | spin_unlock_irqrestore(&cnt->lock, flags); | 149 | spin_unlock_irqrestore(&cnt->lock, flags); |
| 147 | return margin; | 150 | return margin; |
| 148 | } | 151 | } |
