From: sashiko-bot@kernel.org
To: "Hikmah Gumelar" <hikmahgumelar@gmail.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver
Date: Mon, 23 Nov 2026 12:52:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-229271@kernel.org> (raw)
In-Reply-To: <20261123123546.152162-4-hikmahgumelar@gmail.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [High] media: i2c: s5k5e8: broken runtime PM in s5k5e8_probe() and
s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: missing v4l2_subdev_cleanup() in probe()
and remove()
- [Medium] media: i2c: s5k5e8: uninitialized and unupdated active state
in set_format()
- [Medium] media: i2c: s5k5e8: missing exposure update on VBLANK in
s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: missing clock rate and fwnode check in
s5k5e8_probe()
- [Low] media: i2c: s5k5e8: custom CCI helpers, legacy s_stream, and
missing pm_ptr()
- [Low] media: i2c: s5k5e8: missing pm_ptr() wrapper on
s5k5e8_i2c_driver.driver.pm
- [Low] media: i2c: s5k5e8: empty commit message body for new sensor
driver
--
commit e12574756509927d5cb3038e7e50ce4245c96a90
Author: Hikmah Gumelar <hikmahgumelar@gmail.com>
> media: i2c: add s5k5e8 image sensor driver
>
> Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com>
[Severity: Low]
This commit adds a new 500-line image sensor driver with an empty commit
message body. Could a description of the sensor and its supported features
be added to the changelog?
> diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c
> new file mode 100644
> index 0000000000000..80931e5a1c6b2
> --- /dev/null
> +++ b/drivers/media/i2c/s5k5e8.c
[ ... ]
> +static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
> + struct i2c_msg msgs[2];
> + u8 addr_buf[2], data_buf[4] = { 0 };
> + int ret;
> +
> + put_unaligned_be16(reg, addr_buf);
> + msgs[0].addr = client->addr;
> + msgs[0].flags = 0;
> + msgs[0].len = 2;
> + msgs[0].buf = addr_buf;
> + msgs[1].addr = client->addr;
> + msgs[1].flags = I2C_M_RD;
> + msgs[1].len = len;
> + msgs[1].buf = &data_buf[4 - len];
> + ret = i2c_transfer(client->adapter, msgs, 2);
> + if (ret != 2)
> + return ret < 0 ? ret : -EIO;
> + *val = get_unaligned_be32(data_buf);
> + return 0;
> +}
> +
> +static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
> + u8 buf[6];
> + int ret;
> +
> + put_unaligned_be16(reg, buf);
> + put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
> + ret = i2c_master_send(client, buf, len + 2);
> + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO);
> +}
> +
> +static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len)
> +{
> + u32 i;
> + int ret;
> +
> + for (i = 0; i < len; i++) {
> + ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val);
> + if (ret)
> + return ret;
> + }
> + return 0;
> +}
[Severity: Low]
This isn't a bug, but s5k5e8_read_reg(), s5k5e8_write_reg(), and
s5k5e8_write_regs() duplicate the standard V4L2 CCI regmap helpers. Could
this driver select V4L2_CCI_I2C and use devm_cci_regmap_init_i2c(),
cci_read(), cci_write(), and cci_multi_reg_write() instead? Likewise, new
sensor drivers should implement v4l2_subdev_pad_ops.enable_streams and
.disable_streams with v4l2_subdev_s_stream_helper rather than manual
s5k5e8->streaming tracking in .s_stream, and wrap s5k5e8_pm_ops with
pm_ptr().
[ ... ]
> +static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler);
> + int ret = 0;
> +
> + if (!pm_runtime_get_if_in_use(s5k5e8->dev))
> + return 0;
> + switch (ctrl->id) {
> + case V4L2_CID_ANALOGUE_GAIN:
> + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_ANALOG_GAIN, 2, ctrl->val);
> + break;
> + case V4L2_CID_EXPOSURE:
> + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_EXPOSURE, 2, ctrl->val);
> + break;
> + case V4L2_CID_VBLANK:
> + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_VTS, 2,
> + s5k5e8->cur_mode->height + ctrl->val);
> + break;
> + case V4L2_CID_TEST_PATTERN:
> + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_TEST_PATTERN, 2, ctrl->val);
> + break;
> + }
> + pm_runtime_put(s5k5e8->dev);
> + return ret;
> +}
[Severity: High]
Can s5k5e8_set_ctrl() underflow dev->power.usage_count and write to the
sensor while runtime PM is disabled?
pm_runtime_get_if_in_use() returns -EINVAL without incrementing usage_count
when runtime PM is disabled (or when CONFIG_PM is unset). Because
!-EINVAL is false, s5k5e8_set_ctrl() proceeds with I2C writes and then
calls an unbalanced pm_runtime_put(). In addition, s5k5e8_probe() calls
v4l2_async_register_subdev_sensor() before pm_runtime_set_active() and
pm_runtime_enable(), so if the bridge notifier is already registered, the
subdevice can be bound and accessed while runtime PM is still disabled,
causing pm_runtime_resume_and_get() in s5k5e8_set_stream() to fail with
-EACCES.
Checking pm_runtime_get_if_in_use(s5k5e8->dev) <= 0 and enabling runtime PM
before v4l2_async_register_subdev_sensor() (with proper unwind on error)
would avoid both issues.
[Severity: Medium]
Should V4L2_CID_VBLANK in s5k5e8_set_ctrl() also update the maximum range
of s5k5e8->exposure?
s5k5e8_init_controls() initializes V4L2_CID_EXPOSURE with a maximum of 1964
lines (vts_def - 4), but changing V4L2_CID_VBLANK never calls
__v4l2_ctrl_modify_range() on s5k5e8->exposure before the
pm_runtime_get_if_in_use() check. As a result, userspace cannot increase
exposure beyond 1964 lines after increasing vertical blanking.
[ ... ]
> +static int s5k5e8_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state,
> + struct v4l2_subdev_format *fmt)
> +{
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> +
> + s5k5e8_update_pad_format(&supported_modes[0], &fmt->format);
> + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
> + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
> + else
> + s5k5e8->cur_mode = &supported_modes[0];
> +
> + return 0;
> +}
[ ... ]
> +static int s5k5e8_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> +{
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> +
> + mutex_lock(&s5k5e8->mutex);
> + s5k5e8_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, 0));
> + mutex_unlock(&s5k5e8->mutex);
> + return 0;
> +}
[Severity: Medium]
Does this leave sd->active_state->pads[0].format permanently zeroed?
s5k5e8_probe() calls v4l2_subdev_init_finalize(), which initializes
sd->active_state via internal_ops->init_state, but s5k5e8_internal_ops only
provides .open (which initializes per-filehandle fh->state on devnode
open). Furthermore, s5k5e8_set_format() only writes to
*v4l2_subdev_state_get_format(sd_state, fmt->pad) when fmt->which is
V4L2_SUBDEV_FORMAT_TRY. Any bridge driver or V4L2 helper querying the
active format from sd->active_state will see width, height, and media bus
code as 0.
Implementing .init_state in s5k5e8_internal_ops and unconditionally
updating *v4l2_subdev_state_get_format(sd_state, fmt->pad) in
s5k5e8_set_format() would also allow replacing s5k5e8_get_format() with
v4l2_subdev_get_fmt.
[ ... ]
> +static int s5k5e8_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct s5k5e8 *s5k5e8;
> + u32 val = 0;
> + unsigned int i;
> + int ret;
> +
> + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL);
> + if (!s5k5e8)
> + return -ENOMEM;
> + s5k5e8->dev = dev;
> + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops);
> + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
> + if (IS_ERR(s5k5e8->xvclk))
> + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n");
> + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
[Severity: Medium]
Should s5k5e8_probe() validate the xvclk frequency and the fwnode endpoint
configuration?
clk_set_rate() is called without checking its return value or verifying via
clk_get_rate() that the clock rate matches S5K5E8_XVCLK_FREQ (24 MHz),
which can leave the sensor PLL and MIPI link frequency misconfigured if a
different rate is supplied. In addition, s5k5e8_probe() never parses the
fwnode endpoint via v4l2_fwnode_endpoint_alloc_parse() to verify that the
configured data-lanes and link-frequencies match the 2-lane, 418 MHz
register settings hardcoded in the driver.
[ ... ]
> + s5k5e8->sd.state_lock = &s5k5e8->mutex;
> + ret = v4l2_subdev_init_finalize(&s5k5e8->sd);
> + if (ret)
> + goto err_media;
> + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd);
> + if (ret)
> + goto err_media;
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + pm_runtime_idle(dev);
> + return 0;
> +err_media: media_entity_cleanup(&s5k5e8->sd.entity);
> +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler);
> +err_mutex: mutex_destroy(&s5k5e8->mutex);
> +err_power: s5k5e8_power_off(dev);
> + return ret;
> +}
> +
> +static void s5k5e8_remove(struct i2c_client *client)
> +{
> + struct v4l2_subdev *sd = i2c_get_clientdata(client);
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> +
> + v4l2_async_unregister_subdev(sd);
> + media_entity_cleanup(&sd->entity);
> + v4l2_ctrl_handler_free(sd->ctrl_handler);
> + mutex_destroy(&s5k5e8->mutex);
> + pm_runtime_disable(&client->dev);
> + if (!pm_runtime_status_suspended(&client->dev))
> + s5k5e8_power_off(&client->dev);
> + pm_runtime_set_suspended(&client->dev);
> +}
[Severity: Medium]
Does this leak sd->active_state when v4l2_async_register_subdev_sensor()
fails or when s5k5e8_remove() runs?
v4l2_subdev_init_finalize() allocates sd->active_state, and
v4l2_async_register_subdev_sensor() populates
sd->async_subdev_endpoint_list, but neither the error path after
v4l2_subdev_init_finalize() nor s5k5e8_remove() calls
v4l2_subdev_cleanup(sd).
> +
> +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off,
> + s5k5e8_power_on, NULL) };
> +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } };
> +MODULE_DEVICE_TABLE(of, s5k5e8_of_match);
> +static struct i2c_driver s5k5e8_i2c_driver = {
> + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match },
[Severity: Low]
Should s5k5e8_pm_ops use DEFINE_RUNTIME_DEV_PM_OPS() and be assigned via
pm_ptr(&s5k5e8_pm_ops) so the PM structure and callbacks can be dropped by
the compiler when CONFIG_PM is disabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123123546.152162-1-hikmahgumelar@gmail.com?part=3
next prev parent reply other threads:[~2026-11-23 12:52 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 12:42 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 12:43 ` sashiko-bot
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 12:52 ` sashiko-bot [this message]
2026-11-23 13:56 ` Uwe Kleine-König
2026-11-23 14:14 ` Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 12:45 ` sashiko-bot
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 12:35 ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 12:57 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 12:49 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:52 ` sashiko-bot
2026-11-23 15:27 ` [PATCH v3 0/7] " Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 19:18 ` Abel Vesa
2026-11-23 15:27 ` [PATCH v3 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 17:25 ` Konrad Dybcio
2026-11-23 15:27 ` [PATCH v3 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 15:53 ` sashiko-bot
2026-11-23 15:27 ` [PATCH v3 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 15:50 ` sashiko-bot
2026-11-23 15:27 ` [PATCH v3 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 15:46 ` 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=sashiko-outbox-229271@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hikmahgumelar@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.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.