Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kaustabh Chakraborty" <kauschluss@disroot.org>
Cc: linux-input@vger.kernel.org, conor+dt@kernel.org,
	dmitry.torokhov@gmail.com, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 4/5] dt-bindings: input/ts/zinitix: document mode 0
Date: Thu, 30 Jul 2026 19:56:29 +0000	[thread overview]
Message-ID: <20260730195629.A364B1F00ACF@smtp.kernel.org> (raw)
In-Reply-To: <20260731-zinitix-modes-v2-4-ffe2ec9a9031@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Race condition during probe where the input device is registered before device properties are fully read, leading to a state mismatch and a NULL pointer dereference crash.
--

--- Patch [4]: [PATCH v2 4/5] dt-bindings: input/ts/zinitix: document mode 0 ---
commit 68cae6b2efa127f7ca443fe7f4819ab411c887fb
Author: Kaustabh Chakraborty <kauschluss@disroot.org>

dt-bindings: input/ts/zinitix: document mode 0

Zinitix touchscreens support three modes, numbered 0 to 2. This commit
adds mode 0 to the devicetree schema as it was previously unmentioned.

> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml
> index f1ce837b16dfa..9b51212ea9b97 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml
> +++ b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml
> @@ -76,9 +76,9 @@ properties:
>    zinitix,mode:
>      description: Mode of reporting touch points. Some modes may not work
>        with a particular ts firmware for unknown reasons. Available modes are
> -      1 and 2. Mode 2 is the default and preferred.
> +      0, 1, and 2. Mode 2 is the default and preferred.
>      $ref: /schemas/types.yaml#/definitions/uint32
> -    enum: [1, 2]
> +    enum: [0, 1, 2]

[Severity: High]
This is a pre-existing issue, but does adding mode 0 highlight a race 
condition in the driver's initialization sequence?

Looking at drivers/input/touchscreen/zinitix.c, the input device is 
registered before the properties are read:

drivers/input/touchscreen/zinitix.c:zinitix_ts_probe() {
        error = zinitix_init_input_dev(bt541);
        if (error) {
                ...
        }

        error = device_property_read_u32(&client->dev, "zinitix,mode",
                                         &bt541->zinitix_mode);
        ...
        switch (bt541->zinitix_mode) {
        case 0:
                bt541->read_point_status = zinitix_read_point_status_mode0;
                break;
        ...
        }
}

If userspace rapidly opens the device (e.g., via udevd) right after
zinitix_init_input_dev() is called, zinitix_start() will run and call 
enable_irq(). 

If an interrupt fires before probe() reaches the switch statement and assigns
the bt541->read_point_status function pointer, could this result in a NULL 
pointer dereference in the interrupt handler?

drivers/input/touchscreen/zinitix.c:zinitix_ts_irq_handler() {
        ...
        error = bt541->read_point_status(bt541, &touch_event);
        ...
}

Should the property reading and function pointer initialization be moved
before the input device is registered to prevent this?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-zinitix-modes-v2-0-ffe2ec9a9031@disroot.org?part=4

  reply	other threads:[~2026-07-30 19:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 19:48 [PATCH v2 0/5] Support zinitix touch modes 0 and 1, dt changes to Galaxy J6 (j6lte) Kaustabh Chakraborty
2026-07-30 19:48 ` [PATCH v2 1/5] Input: zinitix - check all available fingers for every touch event Kaustabh Chakraborty
2026-07-30 19:59   ` sashiko-bot
2026-07-30 19:48 ` [PATCH v2 2/5] Input: zinitix - do not ignore non-moving fingers Kaustabh Chakraborty
2026-07-30 19:58   ` sashiko-bot
2026-07-30 19:48 ` [PATCH v2 3/5] Input: zinitix - add support for modes 0 and 1 Kaustabh Chakraborty
2026-07-30 20:00   ` sashiko-bot
2026-07-30 19:48 ` [PATCH v2 4/5] dt-bindings: input/ts/zinitix: document mode 0 Kaustabh Chakraborty
2026-07-30 19:56   ` sashiko-bot [this message]
2026-07-30 19:48 ` [PATCH v2 5/5] arm64: dts: exynos7870-j6lte: set mode 0 as default for zinitix touchscreen Kaustabh Chakraborty
2026-07-30 20:01   ` 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=20260730195629.A364B1F00ACF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kauschluss@disroot.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