Repository navigation
soc: apple: pmgr-misc: test the ioremap result with IS_ERR - #337
Conversation
devm_platform_ioremap_resource_byname() returns an ERR_PTR, never NULL, when the named register window is missing. The driver tested for NULL, so a device tree without a fabric-ps or dcs-ps window went on to read through the error pointer. The intent of the check is that a missing window means the device is absent; test for the error pointer. Signed-off-by: Joshua Warren <[email protected]>
|
[Joshua's agent] Review result for this head, from an agent reviewer reading the diff and the kernel source: GREEN on 237e806
|
scottjones
left a comment
There was a problem hiding this comment.
The change is right. In this tree devm_platform_ioremap_resource_byname() goes through devm_ioremap_resource(), which returns IOMEM_ERR_PTR() on every failure path and never NULL (drivers/base/platform.c:148, lib/devres.c:136). So the old !base test could never catch a missing window. With IS_ERR the function returns false, probe treats that as "absent" as intended, and base is stored only after the check, so the later .base NULL tests stay correct.
Built clean with W=1 on aarch64. Both in-tree DTs name fabric-ps and dcs-ps, so this is hardening rather than a crash anyone is hitting today.
Two small things, neither blocking:
- A trailer would help anyone picking this up: Fixes: ae69cad ("soc: apple: Add driver for Apple PMGR misc controls"). That's the copy blame points to here (the same patch also landed as fa7e09c).
- A missing window still logs "invalid resource (null)" at error level even though probe succeeds. If absence is meant to be normal, checking platform_get_resource_byname() for NULL first would keep it quiet. That can be a later change.
|
Note 🤖 GPT-6.1 Terra responding on behalf of Joshua Warren The current checks pass on Scott, could you merge this when ready? |
|
Note anthropic/claude-opus-5-5 responding on behalf of joshuawarren Scott, a short follow-up: this is still approved at head |
c20794c
[Joshua's agent]
apple_pmgr_init_device()maps thefabric-psanddcs-pswindows withdevm_platform_ioremap_resource_byname()and then tests the result withif (!base). That function returns anERR_PTR, never NULL, when the window is missing, so a device tree without one of the two windows goes on toreadl_relaxed()through the error pointer.The intent of the check is plain: a missing window means that system device is absent and
apple_pmgr_init_device()returns false, so probe still succeeds with the other one. This changes the test toIS_ERR(base), which makes the code do that.Checked by reading only: the one-line change, no other file. Not built and not booted; I have no device tree that lacks one of the windows to reproduce it, so the failing case is from the function's return contract, not from a crash I saw.