Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Hefei <3066883572@qq.com>, dri-devel@lists.freedesktop.org
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v4 5/6] Input: add Jadard JD9365TX in-cell touchscreen driver
Date: Wed, 25 Nov 2026 02:49:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-232421@kernel.org> (raw)
In-Reply-To: <tencent_05AAFCF8CA47B5D5ED770621DB13E46F1406@qq.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] Input: jadard_jd9365tx: wrong supply array type in
  jadard_tp_probe()
- [Low] Input: jadard_jd9365tx: u32 overflow in jd_resolve_coord_addr()
  bounds check
--

commit 57a37b18fbb37602183e66793eebea170b919dc2
Author: Hefei <3066883572@qq.com>

Input: add Jadard JD9365TX in-cell touchscreen driver

This commit adds a polling I2C touchscreen driver for the Jadard JD9365TX
in-cell touch controller.

> diff --git a/drivers/input/touchscreen/jadard_jd9365tx.c b/drivers/input/touchscreen/jadard_jd9365tx.c
> new file mode 100644
> index 0000000000000..3312119d7b696
> --- /dev/null
> +++ b/drivers/input/touchscreen/jadard_jd9365tx.c
> @@ -0,0 +1,356 @@

[ ... ]

> +struct jadard_tp {
> +	struct i2c_client *client;
> +	struct input_dev *input;
> +	struct touchscreen_properties prop;
> +	struct gpio_desc *reset;
> +	struct regulator *vdd;
> +	struct regulator *iovcc;
> +	u32 coord_addr;
> +	u16 touch_data_size;
> +	u16 max_points;
> +	unsigned int poll_interval_ms;
> +};

[ ... ]

> +static int jd_resolve_coord_addr(struct jadard_tp *ts)
> +{
> +	u32 esram_num_addr = JD_ERAM_BASE + 4 + JD_MAX_DSRAM_NUM * 8;
> +	u32 esram_sec_addr = esram_num_addr + 4;
> +	u8 buf[JD_ESRAM_SECTION_NUM * 8];
> +	u32 addr, len;
> +	int ret;
> +
> +	ret = jd_read_reg(ts->client, esram_sec_addr, buf, sizeof(buf));
> +	if (ret)
> +		return ret;
> +
> +	addr = get_unaligned_le32(&buf[JD_ESRAM_COORD_IDX * 8]);
> +	len = get_unaligned_le32(&buf[JD_ESRAM_COORD_IDX * 8 + 4]);
> +
> +	if (addr < JD_ERAM_BASE ||
> +	    addr + len > JD_ERAM_BASE + 0x1000 ||
> +	    len < JD_REPORT_MIN_SIZE || len > JD_TOUCH_DATA_SIZE)
> +		return -EINVAL;

[Severity: Low]
Can the 32-bit addition addr + len wrap around here?  If the controller
returns a corrupted section descriptor with addr near U32_MAX and len in
[JD_REPORT_MIN_SIZE, JD_TOUCH_DATA_SIZE], addr + len wraps to a small
value below JD_ERAM_BASE + 0x1000 and jd_resolve_coord_addr() accepts an
invalid coordinate address instead of falling back to
JD_DEFAULT_COORD_ADDR.  Checking len first and testing
addr > JD_ERAM_BASE + 0x1000 - len avoids the overflow.

[ ... ]

> +static int jadard_tp_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct jadard_tp *ts;
> +	struct input_dev *input;
> +	struct regulator_bulk_data supplies[2];
> +	u32 val;
> +	int error;
> +
> +	ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
> +	if (!ts)
> +		return -ENOMEM;
> +
> +	ts->client = client;
> +	ts->max_points = JD_MAX_POINTS;
> +	ts->poll_interval_ms = JD_DEFAULT_POLL_MS;
> +	ts->touch_data_size = JD_TOUCH_DATA_SIZE;
> +	ts->coord_addr = JD_DEFAULT_COORD_ADDR;
> +
> +	supplies[0].supply = "vdd";
> +	supplies[1].supply = "iovcc";
> +	error = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
> +					       supplies);

[Severity: High]
Does passing struct regulator_bulk_data * to
devm_regulator_bulk_get_enable() fail to build with
-Werror=incompatible-pointer-types?  devm_regulator_bulk_get_enable()
takes a const char * const * array of supply names, so if built without
that error it also reads uninitialized stack memory
(supplies[0].consumer) as the second supply name pointer.  Using static
const char * const supplies[] = { "vdd", "iovcc" } fixes this, and the
unused vdd and iovcc fields in struct jadard_tp can be dropped as well.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_7B5CDF8F84744FFBBFCFA89FE3651F675608@qq.com?part=5

  reply	other threads:[~2026-11-25  2:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261125024226.1293-1-3066883572@qq.com>
2026-11-25  2:42 ` [PATCH v4 1/6] dt-bindings: display: add VIEWE 7KF82 JD9365TX panel Hefei
2026-11-25  2:42 ` [PATCH v4 2/6] dt-bindings: input: add Jadard JD9365TX touchscreen Hefei
2026-11-25  2:42 ` [PATCH v4 3/6] dt-bindings: backlight: add VIEWE 7KF82 I2C backlight Hefei
2026-11-25  2:42 ` [PATCH v4 4/6] drm/panel: add VIEWE JD9365TX 7 inch DSI panel Hefei
2026-11-25  2:53   ` sashiko-bot
2026-11-25  2:42 ` [PATCH v4 5/6] Input: add Jadard JD9365TX in-cell touchscreen driver Hefei
2026-11-25  2:49   ` sashiko-bot [this message]
2026-11-25  2:42 ` [PATCH v4 6/6] backlight: add VIEWE 7KF82 I2C backlight driver Hefei

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-232421@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=3066883572@qq.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-input@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox