All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wenmeng Liu" <wenmeng.liu@oss.qualcomm.com>
Cc: robh@kernel.org, media-ci@linuxtv.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/2] media: i2c: Add Samsung S5KJN5 image sensor driver
Date: Thu, 06 Aug 2026 04:04:45 +0000	[thread overview]
Message-ID: <20260806040446.3E2D11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-sk5jn5-v3-2-0b3ac1eadf8a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] NULL pointer dereference in `s5kjn5_set_fmt` when `state` is NULL.
- [High] Incorrect hardware power sequencing between the reset GPIO and the input clock.
--

--- Patch [2]: [PATCH v3 2/2] media: i2c: Add Samsung S5KJN5 image sensor driver ---
commit 0c20120b2e36399c4fc0b31ce99ece2819948b3a
Author: Wenmeng Liu <wenmeng.liu@oss.qualcomm.com>

media: i2c: Add Samsung S5KJN5 image sensor driver

This commit adds a V4L2 sub-device driver for the Samsung S5KJN5, a 50 MP
10-bit RAW MIPI CSI-2 image sensor. It supports the 4096x3072 mode and
exposes standard V4L2 controls.

> diff --git a/drivers/media/i2c/s5kjn5.c b/drivers/media/i2c/s5kjn5.c
> new file mode 100644
> index 0000000000000..02ba83af9965e
> --- /dev/null
> +++ b/drivers/media/i2c/s5kjn5.c
[ ... ]
> +static int s5kjn5_power_on(struct device *dev)
> +{
> +	struct v4l2_subdev *sd = dev_get_drvdata(dev);
> +	struct s5kjn5 *s5kjn5 = sd_to_s5kjn5(sd);
> +	int ret;
> +
> +	ret = regulator_bulk_enable(S5KJN5_NUM_SUPPLIES, s5kjn5->supplies);
> +	if (ret) {
> +		dev_err(dev, "failed to enable regulators: %d\n", ret);
> +		return ret;
> +	}
> +
> +	gpiod_set_value_cansleep(s5kjn5->reset_gpio, 0);
> +	usleep_range(8000, 10000);
> +
> +	ret = clk_prepare_enable(s5kjn5->inclk);

[Severity: High]
Will this hardware sequence fail on some devices? Standard hardware
sequencing for MIPI CSI-2 image sensors usually requires the external clock
to be running before the chip is brought out of reset, allowing its internal
logic and state machines to safely initialize.

[ ... ]
> +static int s5kjn5_power_off(struct device *dev)
> +{
> +	struct v4l2_subdev *sd = dev_get_drvdata(dev);
> +	struct s5kjn5 *s5kjn5 = sd_to_s5kjn5(sd);
> +
> +	clk_disable_unprepare(s5kjn5->inclk);
> +	gpiod_set_value_cansleep(s5kjn5->reset_gpio, 1);

[Severity: High]
Does the clock need to remain active until after reset is asserted here?
Disabling the clock before putting the sensor back into reset might leave
the hardware in an invalid state.

[ ... ]
> +static int s5kjn5_set_fmt(struct v4l2_subdev *sd,
> +			  struct v4l2_subdev_state *state,
> +			  struct v4l2_subdev_format *fmt)
> +{
> +	const struct s5kjn5_mode *mode = &s5kjn5_modes[0];
> +	struct v4l2_mbus_framefmt *format;
> +
> +	s5kjn5_fill_format(mode, &fmt->format);
> +
> +	format = v4l2_subdev_state_get_format(state, 0);
> +	*format = fmt->format;

[Severity: High]
Can this cause a null pointer dereference when called by a legacy bridge
driver?

When the kernel is compiled without CONFIG_MEDIA_CONTROLLER, V4L2 core
wrappers do not fall back to the active state if the provided state is null.

If a driver calls v4l2_subdev_call(sd, pad, set_fmt, NULL, &fmt),
the state parameter passed to s5kjn5_set_fmt() will be null. The lookup
function v4l2_subdev_state_get_format() detects the null state, triggers a
warning, and returns null, leading to a crash on the immediate assignment
to *format.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-sk5jn5-v3-0-0b3ac1eadf8a@oss.qualcomm.com?part=2

      reply	other threads:[~2026-08-06  4:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  3:50 [PATCH v3 0/2] media: i2c: Add Samsung S5KJN5 image sensor Wenmeng Liu
2026-08-06  3:50 ` [PATCH v3 1/2] dt-bindings: " Wenmeng Liu
2026-08-06  3:50 ` [PATCH v3 2/2] media: i2c: Add Samsung S5KJN5 image sensor driver Wenmeng Liu
2026-08-06  4:04   ` sashiko-bot [this message]

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=20260806040446.3E2D11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wenmeng.liu@oss.qualcomm.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.