linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Duplicate kernel-doc comments for ksize()
@ 2022-11-07 10:41 Akira Yokosawa
  2022-11-07 16:23 ` Vlastimil Babka
  0 siblings, 1 reply; 2+ messages in thread
From: Akira Yokosawa @ 2022-11-07 10:41 UTC (permalink / raw)
  To: Kees Cook
  Cc: Vlastimil Babka, Jonathan Corbet, Akira Yokosawa, linux-mm, linux-kernel

Hi Kees,

"make htmldocs" reports duplicate C declaration of ksize()
as follows:

/linux/Documentation/core-api/mm-api:43: ./mm/slab_common.c:1428: WARNING: Duplicate C declaration, also defined at core-api/mm-api:212.
Declaration is '.. c:function:: size_t ksize (const void *objp)'.

This is due to the kernel-doc comment for ksize() added in
include/linux/slab.h by a commit you have authored:
  05a940656e1e ("slab:Introduce kmalloc_size_roundup()").

/**
 * ksize - Report actual allocation size of associated object
 *
 * @objp: Pointer returned from a prior kmalloc()-family allocation.
 *
 * This should not be used for writing beyond the originally requested
 * allocation size. Either use krealloc() or round up the allocation size
 * with kmalloc_size_roundup() prior to allocation. If this is used to
 * access beyond the originally requested allocation size, UBSAN_BOUNDS
 * and/or FORTIFY_SOURCE may trip, since they only know about the
 * originally allocated size via the __alloc_size attribute.
 */

There is another kernel-doc comment in mm/slab_common.c (originally
by Manfred, since v2.6.14):

/**
 * ksize - get the actual amount of memory allocated for a given object
 * @objp: Pointer to the object
 *
 * kmalloc may internally round up allocations and return more memory
 * than requested. ksize() can be used to determine the actual amount of
 * memory allocated. The caller may use this additional memory, even though
 * a smaller amount of memory was initially specified with the kmalloc call.
 * The caller must guarantee that objp points to a valid object previously
 * allocated with either kmalloc() or kmem_cache_alloc(). The object
 * must not be freed during the duration of the call.
 *
 * Return: size of the actual memory used by @objp in bytes
 */

I guess the one in slab_common.c is outdated and can be removed.
Can you please take care of it?

        Thanks, Akira


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-07 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 10:41 Duplicate kernel-doc comments for ksize() Akira Yokosawa
2022-11-07 16:23 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox