From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: cassel@kernel.org, linux-ide@vger.kernel.org, dlemoal@kernel.org
Subject: Re: [PATCHv2] ata: ahci_tegra: remove devm_kcalloc()
Date: Sat, 30 May 2026 00:52:31 +0000 [thread overview]
Message-ID: <20260530005231.A50A11F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260530004135.43088-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unchecked dereference of `soc` when retrieving `soc->num_supplies` during memory allocation, leading to an immediate kernel panic if `of_device_get_match_data()` returns NULL.
--
commit bf92e6df451c5a93edb05970118c13a24829ffcf
Author: Rosen Penev <rosenp@gmail.com>
ata: ahci_tegra: remove devm_kcalloc()
This commit combines the allocation for the tegra_ahci_priv structure and
its supplies flexible array into a single allocation to remove the use of
devm_kcalloc().
> diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c
> index 554f05e09f983..142ba2ae1c831 100644
> --- a/drivers/ata/ahci_tegra.c
> +++ b/drivers/ata/ahci_tegra.c
[ ... ]
> @@ -514,6 +515,7 @@ static const struct scsi_host_template ahci_platform_sht = {
>
> static int tegra_ahci_probe(struct platform_device *pdev)
> {
> + const struct tegra_ahci_soc *soc;
> struct ahci_host_priv *hpriv;
> struct tegra_ahci_priv *tegra;
> struct resource *res;
> @@ -523,14 +525,15 @@ static int tegra_ahci_probe(struct platform_device *pdev)
> if (IS_ERR(hpriv))
> return PTR_ERR(hpriv);
>
> - tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
> + soc = of_device_get_match_data(&pdev->dev);
> + tegra = devm_kzalloc(&pdev->dev, struct_size(tegra, supplies, soc->num_supplies), GFP_KERNEL);
[Severity: High]
This isn't a bug introduced by this patch, but can of_device_get_match_data()
return NULL if the driver is probed via sysfs bind with driver_override?
If it returns NULL, the immediate dereference of soc->num_supplies in the
struct_size() macro will cause a NULL pointer dereference. While this
vulnerability existed in the codebase before this patch, this patch shifts
the dereference earlier in the probe sequence.
Could a NULL check be added for soc before it is dereferenced?
> if (!tegra)
> return -ENOMEM;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260530004135.43088-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-05-30 0:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 0:41 [PATCHv2] ata: ahci_tegra: remove devm_kcalloc() Rosen Penev
2026-05-30 0:52 ` sashiko-bot [this message]
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=20260530005231.A50A11F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=rosenp@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox