Skip to content

pwm: rp1: use pwmchip_get_drvdata() instead of container_of()#6972

Merged
pelwell merged 1 commit intoraspberrypi:rpi-6.12.yfrom
nbuchwitz:devel/fix-pwm-pio
Jul 24, 2025
Merged

pwm: rp1: use pwmchip_get_drvdata() instead of container_of()#6972
pelwell merged 1 commit intoraspberrypi:rpi-6.12.yfrom
nbuchwitz:devel/fix-pwm-pio

Conversation

@nbuchwitz
Copy link
Copy Markdown
Contributor

The PWM framework may not embed struct pwm_chip within the driver’s private data. Using container_of() can result in accessing invalid memory or NULL pointers, especially after recent kernel changes.

Switch to pwmchip_get_drvdata() to reliably access the driver data. This resolves kernel warnings and probe failures seen after updating from kernel 6.12.28 to 6.12.34 [1]

[1] #6971

@nbuchwitz
Copy link
Copy Markdown
Contributor Author

Probably broken since the very beginning of 6.12.y

@6by9
Copy link
Copy Markdown
Contributor

6by9 commented Jul 24, 2025

Tested and LGTM.

You could lose the struct pwm_chip chip; from struct pwm_pio_rp1 as it's not used now.

The PWM framework may not embed struct pwm_chip within the driver’s
private data. Using container_of() can result in accessing invalid
memory or NULL pointers, especially after recent kernel changes.

Switch to pwmchip_get_drvdata() to reliably access the driver data.
This resolves kernel warnings and probe failures seen after updating
from kernel 6.12.28 to 6.12.34 [1]

While at it remove the now obsolete `struct pwm_chip chip` member from
`struct pwm_pio_rp1`.

[1] raspberrypi#6971

Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
@nbuchwitz nbuchwitz force-pushed the devel/fix-pwm-pio branch from ec51394 to 44630a4 Compare July 24, 2025 11:22
@nbuchwitz
Copy link
Copy Markdown
Contributor Author

Thanks. I've updated the PR

@pelwell pelwell merged commit aabec9a into raspberrypi:rpi-6.12.y Jul 24, 2025
12 checks passed
@nbuchwitz nbuchwitz deleted the devel/fix-pwm-pio branch July 24, 2025 18:36
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Aug 1, 2025
kernel: drm/v3d: Address race-condition between per-fd GPU stats and fd release
See: raspberrypi/linux#6973

kernel: pwm: rp1: use pwmchip_get_drvdata() instead of container_of()
See: raspberrypi/linux#6972
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Aug 1, 2025
kernel: drm/v3d: Address race-condition between per-fd GPU stats and fd release
See: raspberrypi/linux#6973

kernel: pwm: rp1: use pwmchip_get_drvdata() instead of container_of()
See: raspberrypi/linux#6972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants