Re: [PATCH v2] cleanup: Add usage and style documentation

From: Dan Williams
Date: Tue Mar 26 2024 - 13:50:25 EST


Dan Williams wrote:
[..]
> diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
> index c2d09bc4f976..8ef2d91c2cbf 100644
> --- a/include/linux/cleanup.h
> +++ b/include/linux/cleanup.h
[..]
> + * When the unwind order matters it requires that variables be defined
> + * mid-function scope rather than at the top of the file. Take the
> + * following example and notice the bug highlighted by "!!":
> + *
> + * ::
> + *
> + * LIST_HEAD(list);
> + * DEFINE_MUTEX(lock);
> + *
> + * struct object {
> + * struct list_head node;
> + * };
> + *
> + * static struct object *alloc_add(void)
> + * {
> + * struct object *obj;
> + *
> + * lockdep_assert_held(&lock);
> + * obj = kfree(sizeof(*obj), GFP_KERNEL);

This should be kzalloc(), and I should note that this example is of the
UNTESTED variety.