All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pan Chuang" <panchuang@vivo.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/7] staging: fbtft: Remove redundant dev_err_probe()
Date: Mon, 20 Jul 2026 14:04:33 +0000	[thread overview]
Message-ID: <20260720140433.EAA331F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720134324.239391-3-panchuang@vivo.com>

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

Pre-existing issues:
- [High] The driver relies on static global variables (`irq_te` and `panel_te`) to manage device-specific IRQ and synchronization state, which breaks multi-device configurations and can cause Use-After-Free bugs.
- [Medium] In the display update path `write_vmem()`, the tearing effect (TE) interrupt is enabled before the completion structure is reinitialized, creating a race window that can lead to missed TE events and unnecessary timeouts.
- [Medium] The driver prematurely frees the `te` GPIO descriptor via `gpiod_put(te)` immediately after converting it to an IRQ, allowing the pin to be reconfigured or powered down.
--

--- Patch [2]: [PATCH 2/7] staging: fbtft: Remove redundant dev_err_probe() ---
commit ac4d01370b4ee0a3ff08280bd824b5b8e0c0efe6
Author: Pan Chuang <panchuang@vivo.com>

staging: fbtft: Remove redundant dev_err_probe()
    
Since commit
55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"),
devm_request_irq() automatically logs detailed error messages on
failure. Remove the now-redundant driver-specific dev_err_probe() calls.

> diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c
> index 861a154144e66..ec46ad3f6a918 100644
> --- a/drivers/staging/fbtft/fb_st7789v.c
> +++ b/drivers/staging/fbtft/fb_st7789v.c
> @@ -119,7 +119,7 @@ static int init_tearing_effect_line(struct fbtft_par *par)
>  	rc = devm_request_irq(dev, irq_te, panel_te_handler,
>  			      IRQF_TRIGGER_RISING, "TE_GPIO", par);

[Severity: High]
This isn't a bug introduced by this patch, but does using the global
variables irq_te and panel_te break multi-device configurations?

If multiple displays are probed, the global irq_te will be overwritten.
Subsequent display updates from any panel will then manipulate the irq of
the most recently probed panel.

If one panel is unbound, devres frees its irq, but irq_te retains the freed
irq number, potentially leading to an invalid enable_irq() call on a
released irq.

>  	if (rc)
> -		return dev_err_probe(dev, rc, "TE IRQ request failed.\n");
> +		return rc;
>  
>  	disable_irq_nosync(irq_te);
>  

[Severity: Medium]
This is a pre-existing issue, but does the driver prematurely free the te
gpio descriptor in init_tearing_effect_line() just before this?

drivers/staging/fbtft/fb_st7789v.c:init_tearing_effect_line() {
...
	irq = gpiod_to_irq(te);

	/* GPIO is locked as an IRQ, we may drop the reference */
	gpiod_put(te);

	if (irq < 0)
		return irq;
...
}

Calling gpiod_put() completely frees the descriptor and marks it as
unrequested in the gpiolib core. Doesn't this allow other drivers or
userspace tools to request the gpio and reconfigure its direction, which
would silently break the te interrupt line?

[Severity: Medium]
This isn't a bug introduced by this patch, but is there a race condition in
write_vmem() when enabling the tearing effect interrupt?

drivers/staging/fbtft/fb_st7789v.c:write_vmem() {
...
	if (irq_te) {
		enable_irq(irq_te);
		reinit_completion(&panel_te);
...
}

By enabling the irq before resetting the completion, could an interrupt
arrive in this tiny window?

If it does, the handler completes the event, but the main thread
immediately resets the completion state and waits, missing the event.
Could this regression lead to unnecessary timeouts and framerate drops?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720134324.239391-1-panchuang@vivo.com?part=2

  reply	other threads:[~2026-07-20 14:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 13:43 [PATCH 0/7] staging: Remove redundant error messages on IRQ request failure Pan Chuang
2026-07-20 13:43 ` [PATCH 1/7] staging: axis-fifo: Remove redundant dev_err() Pan Chuang
2026-07-20 13:43 ` [PATCH 2/7] staging: fbtft: Remove redundant dev_err_probe() Pan Chuang
2026-07-20 14:04   ` sashiko-bot [this message]
2026-07-20 18:18   ` Andy Shevchenko
2026-07-20 13:43 ` [PATCH 3/7] staging: greybus: arche-platform: Remove redundant dev_err() Pan Chuang
2026-07-20 13:43 ` [PATCH 4/7] staging: iio: adt7316: " Pan Chuang
2026-07-20 13:43 ` [PATCH 5/7] media: atomisp: " Pan Chuang
2026-07-20 19:11   ` Andy Shevchenko
2026-07-20 13:43 ` [PATCH 6/7] staging: most: dim2: " Pan Chuang
2026-07-20 13:43 ` [PATCH 7/7] staging: nvec: Remove redundant dev_err_probe() Pan Chuang

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=20260720140433.EAA331F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=panchuang@vivo.com \
    --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.