Re: [PATCH v2 09/10] rtc: omap: prevent NULL and dangling pointer dereferences in power-off path
From: Johan Hovold
Date: Thu Dec 03 2026 - 01:59:28 EST
On Wed, Dec 02, 2026 at 08:22:38PM +0000, Lee Jones wrote:
> omap_rtc_power_off_program() is exported and called directly from
> am33xx_rtc_only_idle() during suspend without checking whether
> omap_rtc_power_off_rtc is NULL, causing a NULL pointer dereference if
> omap_rtc_power_off_rtc was never assigned or was cleared on unbind.
> Furthermore, omap_rtc_remove() only clears omap_rtc_power_off_rtc if
> pm_power_off still equals omap_rtc_power_off; if another driver
> overwrote pm_power_off after probe, unbinding the RTC leaves
> omap_rtc_power_off_rtc pointing to freed memory for subsequent calls to
> omap_rtc_power_off_program().
>
> Return -ENODEV from omap_rtc_power_off_program() when
> omap_rtc_power_off_rtc is NULL, and always clear omap_rtc_power_off_rtc
> when removing the matching RTC instance.
>
> Fixes: 5a99ae0092fe ("soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support")
> Closes: https://sashiko.dev/#/bug/linux-97b795c5-f68f-4228-948f-547a106c6775
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---
>
> v1 => v2:
> - Update Fixes: tag to 5a99ae0092fe ("soc: ti: pm33xx: AM437X: Add
> rtc_only with ddr in self-refresh support") and reword the commit
> message accordingly (Johan)
> - Drop the unrelated refactoring in omap_rtc_power_off() (Johan)
Reviewed-by: Johan Hovold <johan@xxxxxxxxxx>