diff --git a/lib/kref.c b/lib/kref.c index 1599dbf..a547ad3 100644 --- a/lib/kref.c +++ b/lib/kref.c @@ -40,7 +40,7 @@ void kref_init(struct kref *kref) */ void kref_get(struct kref *kref) { - WARN_ON(!atomic_read(&kref->refcount)); + WARN_ON(atomic_read(&kref->refcount) <= 0); atomic_inc(&kref->refcount); smp_mb__after_atomic_inc(); } @@ -63,7 +63,7 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref)) { WARN_ON(release == NULL); WARN_ON(release == (void (*)(struct kref *))kfree); - WARN_ON(!atomic_read(&kref->refcount)); + WARN_ON(atomic_read(&kref->refcount) <= 0); if (atomic_dec_and_test(&kref->refcount)) { release(kref);