From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: wsa+renesas@sang-engineering.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 1/9] drm/managed: implement managed versions of kzalloc_obj/objs()
Date: Fri, 12 Jun 2026 18:41:25 +0000 [thread overview]
Message-ID: <20260612184126.A02531F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612-wb-drop-encoder-v6-1-9f3a54f81310@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing explicit return type cast in drmm_kzalloc_objs / drmm_kzalloc_obj permits silent heap buffer overflows.
- [Low] Kernel-doc parameter name mismatch in drmm_kzalloc_obj triggers documentation warnings.
--
commit 852017e1ea6892532ead5eeb34b599432f852a80
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
drm/managed: implement managed versions of kzalloc_obj/objs()
This commit implements drm_device-managed versions of the kzalloc_obj() and
kzalloc_objs() macros. They provide a convenient interface for allocating
objects with automatic freeing via the DRM managed API, defaulting to
GFP_KERNEL.
> diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
> index 72bfac002c062..d196387506c97 100644
> --- a/include/drm/drm_managed.h
> +++ b/include/drm/drm_managed.h
> @@ -105,6 +105,28 @@ static inline void *drmm_kcalloc(struct drm_device *dev,
> return drmm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
> }
>
> +/**
> + * drmm_kzalloc_objs - &drm_device-managed kzalloc_objs()
> + * @dev: DRM device
> + * @p: Variable or type to allocate an array of
> + * @count: How many elements in the array
> + *
> + * Returns: newly allocated pointer to the zeroed array of @P on success, or
> + * NULL on failure.
> + */
> +#define drmm_kzalloc_objs(dev, p, count) \
> + drmm_kcalloc(dev, count, sizeof(typeof(p)), GFP_KERNEL)
[Severity: High]
Does this macro need an explicit return type cast like the standard
kzalloc_objs() macro has?
The standard kzalloc_obj(P) and kzalloc_objs(P, count) macros explicitly cast
their return values to (typeof(P) *). This cast provides a compile-time safety
guard: if a developer mistakenly passes a pointer variable ptr instead of the
dereferenced pointer *ptr (e.g., ptr = kzalloc_obj(ptr)), the macro evaluates
sizeof(typeof(ptr)) (allocating 8 bytes) and returns a double pointer
(typeof(ptr) *). Assigning this back to ptr triggers an "assignment from
incompatible pointer type" compiler warning, catching the error immediately.
Since drmm_kzalloc_objs directly returns void * from drmm_kcalloc, the exact
same mistake (ptr = drmm_kzalloc_obj(dev, ptr)) compiles silently without
warnings because C implicitly casts void * to any pointer type. This allocates
only the 8-byte pointer size instead of the full structure size, which could
lead to a silent out-of-bounds heap overwrite.
Should this macro wrap the drmm_kcalloc call in an explicit ((typeof(p) *) ...)
cast to maintain the API safety guarantees of the standard macros it mimics?
> +
> +/**
> + * drmm_kzalloc_obj - &drm_device-managed kzalloc_obj()
> + * @dev: DRM device
> + * @p: Variable or type to allocate
> + *
> + * Returns: newly allocated pointer to a @p on success, or NULL on failure.
> + */
> +#define drmm_kzalloc_obj(dev, P) \
> + drmm_kzalloc_objs(dev, P, 1)
[Severity: Low]
This isn't a bug, but does the macro parameter case mismatch the kernel-doc?
In the kernel-doc comment for drmm_kzalloc_obj, the parameter is documented
as @p (lowercase). However, the actual macro definition uses P (uppercase)
as the parameter name.
Since kernel-doc is case-sensitive, this mismatch will trigger warnings for
an "Excess function parameter p" and "Function parameter P not described"
during document generation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612-wb-drop-encoder-v6-0-9f3a54f81310@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-06-12 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 18:30 [PATCH v6 0/9] drm: writeback: clean up writeback connector initialization Dmitry Baryshkov
2026-06-12 18:30 ` [PATCH v6 1/9] drm/managed: implement managed versions of kzalloc_obj/objs() Dmitry Baryshkov
2026-06-12 18:41 ` sashiko-bot [this message]
2026-06-12 18:30 ` [PATCH v6 2/9] drm/amd/display: use drmm allocation for writeback connector Dmitry Baryshkov
2026-06-12 18:44 ` sashiko-bot
2026-06-12 18:30 ` [PATCH v6 3/9] drm/amd/display: use drmm_writeback_connector_init() Dmitry Baryshkov
2026-06-12 18:58 ` sashiko-bot
2026-06-12 18:30 ` [PATCH v6 4/9] drm/komeda: " Dmitry Baryshkov
2026-06-12 18:39 ` sashiko-bot
2026-06-12 18:30 ` [PATCH v6 5/9] drm/mali: " Dmitry Baryshkov
2026-06-12 18:40 ` sashiko-bot
2026-06-12 18:30 ` [PATCH v6 6/9] drm: renesas: rcar-du: " Dmitry Baryshkov
2026-06-12 18:30 ` [PATCH v6 7/9] drm/vc4: " Dmitry Baryshkov
2026-06-12 18:44 ` sashiko-bot
2026-06-12 18:30 ` [PATCH v6 8/9] drm: writeback: drop excess connector initialization functions Dmitry Baryshkov
2026-06-12 18:30 ` [PATCH v6 9/9] drm: writeback: rename drm_writeback_connector_init_with_encoder() Dmitry Baryshkov
2026-06-12 18:49 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260612184126.A02531F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.