From: sashiko-bot@kernel.org
To: "Arash Golgol" <arash.golgol@gmail.com>, linux-sunxi@lists.linux.dev
Cc: media-ci@linuxtv.org
Subject: Re: [PATCH v1 1/3] media: sun6i-csi: capture: Align size to 16 for NV12_16L16
Date: Fri, 16 Oct 2026 11:47:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-174251@kernel.org> (raw)
In-Reply-To: <20261016113846.8602-2-arash.golgol@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] media: sun6i-csi: incorrect bytesperline for NV12_16L16 format
--
commit 476de016f26cd243aac004fdf752c97c70ae693b
Author: Arash Golgol <arash.golgol@gmail.com>
media: sun6i-csi: capture: Align size to 16 for NV12_16L16
This commit introduces alignment handling specific to pixel formats in the
sun6i-csi capture driver. It sets the required alignment based on the format
and applies it during format preparation.
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> index d90abba213098..f55edfd0b174a 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
[ ... ]
> @@ -665,17 +671,19 @@ static void sun6i_csi_capture_format_prepare(struct v4l2_format *format)
> {
> struct v4l2_pix_format *pix_format = &format->fmt.pix;
> const struct v4l2_format_info *info;
> - unsigned int width, height;
> -
> - v4l_bound_align_image(&pix_format->width, SUN6I_CSI_CAPTURE_WIDTH_MIN,
> - SUN6I_CSI_CAPTURE_WIDTH_MAX, 1,
> - &pix_format->height, SUN6I_CSI_CAPTURE_HEIGHT_MIN,
> - SUN6I_CSI_CAPTURE_HEIGHT_MAX, 1, 0);
> + unsigned int width, height, align;
>
> if (!sun6i_csi_capture_format_find(pix_format->pixelformat))
> pix_format->pixelformat =
> sun6i_csi_capture_formats[0].pixelformat;
>
> + align = sun6i_csi_capture_format_align(pix_format->pixelformat);
> +
> + v4l_bound_align_image(&pix_format->width, SUN6I_CSI_CAPTURE_WIDTH_MIN,
> + SUN6I_CSI_CAPTURE_WIDTH_MAX, align,
> + &pix_format->height, SUN6I_CSI_CAPTURE_HEIGHT_MIN,
> + SUN6I_CSI_CAPTURE_HEIGHT_MAX, align, 0);
> +
> width = pix_format->width;
> height = pix_format->height;
>
> info = v4l2_format_info(pix_format->pixelformat);
>
> switch (pix_format->pixelformat) {
> case V4L2_PIX_FMT_NV12_16L16:
> pix_format->bytesperline = width * 12 / 8;
[Severity: Medium]
Does this code violate the V4L2 API contract by incorrectly hardcoding
bytesperline to 1.5x width as a shortcut to calculate the correct sizeimage?
The V4L2 specification requires bytesperline to reflect the stride of the
largest plane, which for NV12 is just width. By exposing a stride of
1.5 * width, userspace applications may compute out-of-bounds plane offsets,
potentially leading to memory corruption or crashes within the userspace
client.
This is supported by sun6i_csi_setup_format(), which configures the
hardware using the correct luma and chroma strides of width internally:
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c:sun6i_csi_setup_format() {
...
switch (pixelformat) {
...
case V4L2_PIX_FMT_NV12_16L16:
luma_line = width;
chroma_line = width;
break;
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016113846.8602-1-arash.golgol@gmail.com?part=1
next prev parent reply other threads:[~2026-10-16 11:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 11:38 [PATCH v1 0/3] media: sun6i-csi: Improve capture and bridge Arash Golgol
2026-10-16 11:38 ` [PATCH v1 1/3] media: sun6i-csi: capture: Align size to 16 for NV12_16L16 Arash Golgol
2026-10-16 11:47 ` sashiko-bot [this message]
2026-10-16 11:38 ` [PATCH v1 2/3] media: sun6i-csi: capture: Add enum_framesizes support Arash Golgol
2026-10-16 11:38 ` [PATCH v1 3/3] media: sun6i-csi: bridge: Remove duplicate mbus format entries Arash Golgol
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=sashiko-outbox-174251@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arash.golgol@gmail.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.