From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/3] soc: apple: Add driver for Apple PMGR misc controls
Date: Thu, 02 Jul 2026 12:23:58 +0000 [thread overview]
Message-ID: <20260702122359.0FFEE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702-pmgr-misc-v1-2-4f075a3a95c1@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect check for devm_platform_ioremap_resource_byname() return value leads to ERR_PTR dereference
- [High] Missing NULL check for of_device_get_match_data() causes NULL pointer dereference
--
commit 144dd044ce23e2ad7967536cb164bb8942aedf81
Author: Hector Martin <marcan@marcan.st>
soc: apple: Add driver for Apple PMGR misc controls
This commit adds a driver for managing miscellaneous PMGR controls on Apple
SoCs, implementing fabric and memory controller power state switching on system
standby/s2idle to save power.
> diff --git a/drivers/soc/apple/apple-pmgr-misc.c b/drivers/soc/apple/apple-pmgr-misc.c
> new file mode 100644
> index 0000000000000..d487a87ecddb0
> --- /dev/null
> +++ b/drivers/soc/apple/apple-pmgr-misc.c
[ ... ]
> +static bool apple_pmgr_init_device(struct apple_pmgr_misc *misc,
> + const struct apple_pmgr_misc_hw *hw,
> + enum sys_device dev,
> + const char *device_name)
> +{
> + void __iomem *base;
> + char name[32];
> + u32 val;
> +
> + snprintf(name, sizeof(name), "%s-ps", device_name);
> +
> + base = devm_platform_ioremap_resource_byname(
> + to_platform_device(misc->dev), name);
> + if (!base)
[Severity: High]
Does this code handle the return value of
devm_platform_ioremap_resource_byname() correctly?
The function returns an error pointer on failure, not NULL. A failure here
would bypass this check and could lead to an ERR_PTR being dereferenced by
the readl_relaxed() call below.
> + return false;
> +
> + val = readl_relaxed(base + APPLE_CLKGEN_PSTATE);
> +
> + misc->devices[dev].base = base;
> + misc->devices[dev].active_state =
> + FIELD_GET(APPLE_CLKGEN_PSTATE_DESIRED, val);
> + misc->devices[dev].suspend_state = hw->dev_min_ps[dev];
[Severity: High]
Can hw be NULL here?
If the driver is bound manually via sysfs without a matching device tree node,
of_device_get_match_data() in apple_pmgr_misc_probe() below returns NULL. This
would lead to a NULL pointer dereference.
> +
> + return true;
> +}
> +
> +static int apple_pmgr_misc_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + const struct apple_pmgr_misc_hw *hw;
> + struct apple_pmgr_misc *misc;
> + int ret = -ENODEV;
> +
> + misc = devm_kzalloc(dev, sizeof(*misc), GFP_KERNEL);
> + if (!misc)
> + return -ENOMEM;
> +
> + misc->dev = dev;
> + hw = of_device_get_match_data(dev);
> +
> + if (apple_pmgr_init_device(misc, hw, DEV_FABRIC, "fabric"))
[Severity: High]
Is it possible for hw to be NULL here?
Passing an unchecked hw pointer to apple_pmgr_init_device() causes the
unconditional dereference of hw->dev_min_ps[dev] shown above.
> + ret = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260702-pmgr-misc-v1-0-4f075a3a95c1@chaosmail.tech?part=2
next prev parent reply other threads:[~2026-07-02 12:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:06 [PATCH 0/3] soc: apple: Add "PMGR misc" power controls driver Sasha Finkelstein
2026-07-02 12:06 ` [PATCH 1/3] dt-bindings: soc: apple: Add bindings for apple PMGR misc controls Sasha Finkelstein
2026-07-02 19:18 ` Conor Dooley
2026-07-02 19:35 ` Sasha Finkelstein
2026-07-03 9:52 ` Krzysztof Kozlowski
2026-07-02 12:06 ` [PATCH 2/3] soc: apple: Add driver for Apple " Sasha Finkelstein
2026-07-02 12:23 ` sashiko-bot [this message]
2026-07-02 12:06 ` [PATCH 3/3] arm64: dts: apple: Add pmgr-misc nodes to t60xx Sasha Finkelstein
2026-07-02 12:29 ` 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=20260702122359.0FFEE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=k@chaosmail.tech \
--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