* [PATCHv2] ata: sata_mv: Use platform_get_irq() to get interrupt
@ 2026-07-12 22:20 Rosen Penev
2026-07-12 22:31 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-12 22:20 UTC (permalink / raw)
To: linux-ide; +Cc: Damien Le Moal, Niklas Cassel, open list
Extract platform_get_irq() out of the conditional block to run it
unconditionally, replacing the direct use of irq_of_parse_and_map()
for DT-based systems. This simplifies the probe logic and avoids the
need for irq_dispose_mapping.
Remove dead branch for platform_get_irq(). It intercepts 0 and returns
-EINVAL, which goes to the first one.
Assisted-by: Antigravity:Gemini-3.5-Flash
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: remove dead branch
drivers/ata/sata_mv.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 41647a56a9f4..a2bf9551a600 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4054,17 +4054,13 @@ static int mv_platform_probe(struct platform_device *pdev)
n_ports);
return -EINVAL;
}
-
- irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
} else {
mv_platform_data = dev_get_platdata(&pdev->dev);
n_ports = mv_platform_data->n_ports;
- irq = platform_get_irq(pdev, 0);
}
+ irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
- if (!irq)
- return -EINVAL;
host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] ata: sata_mv: Use platform_get_irq() to get interrupt
2026-07-12 22:20 [PATCHv2] ata: sata_mv: Use platform_get_irq() to get interrupt Rosen Penev
@ 2026-07-12 22:31 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-12 22:31 UTC (permalink / raw)
To: Rosen Penev; +Cc: dlemoal, cassel, linux-ide
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing NULL check for `mv_platform_data` causes a kernel panic if the driver is bound to a device without platform data.
- [High] The `pdev->num_resources != 1` check prevents initialization on legacy platforms that provide multiple resources.
- [High] Unbalanced clock cleanup in error path triggers CCF warnings.
- [High] Clock resource leak when port PHY retrieval fails.
--
--- Patch [1]: [PATCHv2] ata: sata_mv: Use platform_get_irq() to get interrupt ---
commit a89dd91d3fc9df13b699dc2ac8e0b99f240449bf
Author: Rosen Penev <rosenp@gmail.com>
ata: sata_mv: Use platform_get_irq() to get interrupt
Extract platform_get_irq() out of the conditional block to run it
unconditionally, replacing the direct use of irq_of_parse_and_map()
for DT-based systems. This simplifies the probe logic and avoids the
need for irq_dispose_mapping. Remove dead branch for platform_get_irq().
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 41647a56a9f4e..a2bf9551a6008 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4054,17 +4054,13 @@ static int mv_platform_probe(struct platform_device *pdev)
> n_ports);
> return -EINVAL;
> }
> -
> - irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> } else {
> mv_platform_data = dev_get_platdata(&pdev->dev);
> n_ports = mv_platform_data->n_ports;
[Severity: High]
This is a pre-existing issue, but is there a missing NULL check here?
If the driver is manually bound via sysfs to a platform device lacking platform
data (and without a device tree node), dev_get_platdata() returns NULL, which
is immediately dereferenced when accessing n_ports. Could this cause a panic?
> - irq = platform_get_irq(pdev, 0);
> }
> + irq = platform_get_irq(pdev, 0);
> if (irq < 0)
> return irq;
> - if (!irq)
> - return -EINVAL;
>
> host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
> hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
[Severity: High]
This isn't a bug introduced by this patch, but does the strict resource
validation in mv_platform_probe() prevent initialization on legacy platforms?
drivers/ata/sata_mv.c:mv_platform_probe() {
...
if (unlikely(pdev->num_resources != 1)) {
dev_err(&pdev->dev, "invalid number of resources\n");
return -EINVAL;
}
...
}
Legacy board files instantiate the sata_mv platform device with two resources
(an IORESOURCE_MEM and an IORESOURCE_IRQ). This validation causes the probe to
immediately abort with -EINVAL. Could this render the SATA controller unusable
on legacy Orion boards?
[Severity: High]
This is a pre-existing issue, but does the cleanup path in mv_platform_probe()
unbalance the clock enable count?
drivers/ata/sata_mv.c:mv_platform_probe() {
...
hpriv->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(hpriv->clk)) {
dev_notice(&pdev->dev, "cannot get optional clkdev\n");
} else {
rc = clk_prepare_enable(hpriv->clk);
if (rc)
goto err;
}
...
err:
if (!IS_ERR(hpriv->clk)) {
clk_disable_unprepare(hpriv->clk);
clk_put(hpriv->clk);
}
...
}
If clk_prepare_enable(hpriv->clk) fails, the code branches to the err label.
Because !IS_ERR(hpriv->clk) evaluates to true (the pointer is valid), the
cleanup path attempts to disable the clock despite the initialization failure.
Does this trigger a WARN_ON in the Common Clock Framework?
[Severity: High]
This is a pre-existing issue, but is there a clock resource leak in
mv_platform_probe() when port PHY retrieval fails?
drivers/ata/sata_mv.c:mv_platform_probe() {
...
for (port = 0; port < n_ports; port++) {
...
hpriv->port_clks[port] = clk_get(&pdev->dev, port_number);
if (!IS_ERR(hpriv->port_clks[port]))
clk_prepare_enable(hpriv->port_clks[port]);
sprintf(port_number, "port%d", port);
hpriv->port_phys[port] = devm_phy_optional_get(&pdev->dev,
port_number);
if (IS_ERR(hpriv->port_phys[port])) {
rc = PTR_ERR(hpriv->port_phys[port]);
hpriv->port_phys[port] = NULL;
...
hpriv->n_ports = port;
goto err;
} else
...
err:
...
for (port = 0; port < hpriv->n_ports; port++) {
if (!IS_ERR(hpriv->port_clks[port])) {
clk_disable_unprepare(hpriv->port_clks[port]);
clk_put(hpriv->port_clks[port]);
}
phy_power_off(hpriv->port_phys[port]);
}
...
}
Inside the per-port initialization loop, hpriv->port_clks[port] is obtained
and enabled. Immediately after, devm_phy_optional_get() is called. If this
fails (e.g., returning -EPROBE_DEFER), the error handler sets
hpriv->n_ports = port and jumps to the err label.
The cleanup loop iterates up to hpriv->n_ports - 1, thereby skipping the
current port and failing to call clk_disable_unprepare() and clk_put() on the
successfully acquired clock. Can this cause a clock reference leak that
accumulates if the PHY driver defers probing?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260712222003.1008136-1-rosenp@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-12 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 22:20 [PATCHv2] ata: sata_mv: Use platform_get_irq() to get interrupt Rosen Penev
2026-07-12 22:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox