Skip to content

Commit

Permalink
Mark res_counter_charge(_locked) with __must_check
Browse files Browse the repository at this point in the history
Ignoring their return values may result in counter underflow in the future -
when the value charged will be uncharged (or in "leaks" - when the value is
not uncharged).

This also prevents from using charging routines to decrement the
counter value (i.e. uncharge it) ;)

(Current code works OK with res_counter, however :) )

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Pavel Emelyanov authored and Linus Torvalds committed Jul 25, 2008
1 parent 7e9abd8 commit f2992db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/linux/res_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ void res_counter_init(struct res_counter *counter);
* counter->limit _locked call expects the counter->lock to be taken
*/

int res_counter_charge_locked(struct res_counter *counter, unsigned long val);
int res_counter_charge(struct res_counter *counter, unsigned long val);
int __must_check res_counter_charge_locked(struct res_counter *counter,
unsigned long val);
int __must_check res_counter_charge(struct res_counter *counter,
unsigned long val);

/*
* uncharge - tell that some portion of the resource is released
Expand Down

0 comments on commit f2992db

Please sign in to comment.