All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev, linux-gpio@vger.kernel.org
Subject: Re: [PATCH v6 11/13] gpio: mxc: add dev_err_probe() for error paths to help diagnostics
Date: Sun, 11 Oct 2026 12:04:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-167210@kernel.org> (raw)
In-Reply-To: <20261011-gpio-mxc-cleanup-v6-11-cb47ce2ad758@nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] gpio: mxc: race condition exposes uninitialized irq_domain to consumers
- [Low] gpio: mxc: missing dev_err_probe() on clk and irq_count error paths
--

commit 7b3e39d56ce16597ec573873f31010421e588a2f
Author: Peng Fan <peng.fan@nxp.com>

    gpio: mxc: add dev_err_probe() for error paths to help diagnostics

This commit replaces bare returns with dev_err_probe() across the probe error
paths for consistent diagnostics and deferred-probe support.

>     Replace bare return statements with dev_err_probe() across all probe
>     error paths for consistent diagnostics and deferred-probe support.

[Severity: Low]
Is this description accurate?

Looking at mxc_gpio_probe(), bare returns for platform_irq_count() and
devm_clk_get_optional_enabled() are still present:

	irq_count = platform_irq_count(pdev);
	if (irq_count < 0)
		return irq_count;

	...

	port->clk = devm_clk_get_optional_enabled(dev, NULL);
	if (IS_ERR(port->clk))
		return PTR_ERR(port->clk);

Unlike platform_get_irq() or devm_platform_ioremap_resource(), neither of
these functions logs errors or handles probe deferrals internally via
dev_err_probe().

If they fail or defer, the failure might propagate silently without being
recorded in the deferred-probe debugfs list.

Does the commit message need to be updated, or should dev_err_probe() be
added to these error paths?

> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 09acb186c84c1..2847304640f17 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
[ ... ]
> @@ -536,11 +536,11 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>  
>  	err = devm_gpiochip_add_data(dev, &port->gen_gc.gc, port);
>  	if (err)
> -		return err;
> +		return dev_err_probe(dev, err, "Failed to add gpiochip data\n");

[Severity: Medium]
Could this expose an uninitialized irq_domain to consumers?

devm_gpiochip_add_data() exposes the GPIO chip to the system. If a consumer
immediately attempts to translate a GPIO to an IRQ via gpiod_to_irq(),
mxc_gpio_to_irq() is invoked.

This creates a narrow window where mxc_gpio_to_irq() can be called before
devm_irq_domain_instantiate() initializes port->domain.

If this happens, mxc_gpio_to_irq() will pass a NULL domain to
irq_find_mapping():

drivers/gpio/gpio-mxc.c:mxc_gpio_to_irq() {
	...
	return irq_find_mapping(port->domain, offset);
}

This can result in the consumer getting an incorrect IRQ mapping or a
permanent -ENXIO failure from gpiod_to_irq(), leading to a permanent
probe failure instead of -EPROBE_DEFER.

Could we instantiate the irq_domain before adding the GPIO chip?

>  
>  	irq_base = devm_irq_alloc_descs(dev, -1, 0, 32, numa_node_id());
>  	if (irq_base < 0)
> -		return irq_base;
> +		return dev_err_probe(dev, irq_base, "Failed to alloc irq desc\n");

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261011-gpio-mxc-cleanup-v6-0-cb47ce2ad758@nxp.com?part=11

  reply	other threads:[~2026-10-11 12:04 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 11:51 [PATCH v6 00/13] gpio: mxc: bug fixes and probe cleanup Peng Fan (OSS)
2026-10-11 11:51 ` [PATCH v6 01/13] gpio: mxc: fix race between chained IRQ handler install and probe completion Peng Fan (OSS)
2026-10-11 12:05   ` sashiko-bot
2026-10-12  4:14     ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 02/13] gpio: mxc: fix both_edges bit operations Peng Fan (OSS)
2026-10-12  9:18   ` Andy Shevchenko
2026-10-12  9:52     ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 03/13] gpio: mxc: fix wakeup_pads " Peng Fan (OSS)
2026-10-12  9:15   ` Andy Shevchenko
2026-10-12  9:51     ` Peng Fan
2026-10-12 10:30       ` Andy Shevchenko
2026-10-12 11:41         ` Peng Fan
2026-10-12 18:25           ` Andy Shevchenko
2026-10-11 11:51 ` [PATCH v6 04/13] gpio: mxc: use irq_set_irq_wake() to simplify code Peng Fan (OSS)
2026-10-11 11:51 ` [PATCH v6 05/13] gpio: mxc: use for_each_set_bit() to iterate wakeup pads Peng Fan (OSS)
2026-10-12  9:19   ` Andy Shevchenko
2026-10-12  9:53     ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 06/13] gpio: mxc: replace of_device_is_compatible() with hwdata flags Peng Fan (OSS)
2026-10-12  9:25   ` Andy Shevchenko
2026-10-12  9:59     ` Peng Fan
2026-10-12 10:32       ` Andy Shevchenko
2026-10-11 11:51 ` [PATCH v6 07/13] gpio: mxc: convert pad wakeup compatible checks to " Peng Fan (OSS)
2026-10-12  9:27   ` Andy Shevchenko
2026-10-12 10:01     ` Peng Fan
2026-10-12 14:31       ` Frank Li
2026-10-11 11:51 ` [PATCH v6 08/13] gpio: mxc: use local dev variable Peng Fan (OSS)
2026-10-12  9:30   ` Andy Shevchenko
2026-10-12 10:05     ` Peng Fan
2026-10-12 10:39       ` Andy Shevchenko
2026-10-12 11:52         ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 09/13] gpio: mxc: use cleanup guard for pm_runtime_get_noresume() balance Peng Fan (OSS)
2026-10-12  9:38   ` Andy Shevchenko
2026-10-12 10:10     ` Peng Fan
2026-10-12 10:41       ` Andy Shevchenko
2026-10-11 11:51 ` [PATCH v6 10/13] gpio: mxc: use devres functions simplify probe code Peng Fan (OSS)
2026-10-11 12:05   ` sashiko-bot
2026-10-12  4:12     ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 11/13] gpio: mxc: add dev_err_probe() for error paths to help diagnostics Peng Fan (OSS)
2026-10-11 12:04   ` sashiko-bot [this message]
2026-10-12  4:13     ` Peng Fan
2026-10-11 11:51 ` [PATCH v6 12/13] gpio: mxc: introduce MXC_ICR macros and use field_prep/field_get Peng Fan (OSS)
2026-10-11 11:51 ` [PATCH v6 13/13] gpio: mxc: use BIT() macro for single-bit operations Peng Fan (OSS)

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-167210@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-gpio@vger.kernel.org \
    --cc=peng.fan@oss.nxp.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.