Re: [RFC] kref, a tiny, sane, reference count object

Andrew Morton
2004-03-14T00:34:47Z

Greg KH <greg@kroah.com> wrote:
>
> For all of those people, this patch is for you.

It does rather neatly capture a common idiom.

> +struct kref * kref_get(struct kref *kref)
> +{
> + if (kref) {
> + WARN_ON(!atomic_read(&kref->refcount));
> + atomic_inc(&kref->refcount);
> + }
> + return kref;
> +}

Why is a NULL arg permitted here?

> +void kref_cleanup(struct kref *kref)
> +{
> + if (!kref)
> + return;

and here?