]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
res_counter: allow charge failure pointer to be null
authorFrederic Weisbecker <fweisbec@gmail.com>
Fri, 2 Dec 2011 03:12:56 +0000 (14:12 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2011 05:33:02 +0000 (16:33 +1100)
So that callers of res_counter_charge() don't have to create and pass this
pointer even if they aren't interested in it.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Menage <paul@paulmenage.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Aditya Kali <adityakali@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Tim Hockin <thockin@hockin.org>
Cc: Tejun Heo <htejun@gmail.com>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/res_counter.c

index 8f4c728ccee09d1c0e67cdc8dd3111bd981e0750..6b36823541ba903171e5bf642cdea376b7b81832 100644 (file)
@@ -43,14 +43,16 @@ int res_counter_charge_until(struct res_counter *counter,
        unsigned long flags;
        struct res_counter *c, *u;
 
-       *limit_fail_at = NULL;
+       if (limit_fail_at)
+               *limit_fail_at = NULL;
        local_irq_save(flags);
        for (c = counter; c != limit; c = c->parent) {
                spin_lock(&c->lock);
                ret = res_counter_charge_locked(c, val);
                spin_unlock(&c->lock);
                if (ret < 0) {
-                       *limit_fail_at = c;
+                       if (limit_fail_at)
+                               *limit_fail_at = c;
                        goto undo;
                }
        }