]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
soc: xilinx: Shutdown and free rx mailbox channel
authorPrasanna Kumar T S M <ptsm@linux.microsoft.com>
Fri, 20 Mar 2026 06:04:45 +0000 (23:04 -0700)
committerMichal Simek <michal.simek@amd.com>
Thu, 30 Apr 2026 10:50:05 +0000 (12:50 +0200)
A mbox rx channel is requested using mbox_request_channel_byname() in
probe. In remove callback, the rx mailbox channel is cleaned up when the
rx_chan is NULL due to incorrect condition check. The mailbox channel is
not shutdown and it can receive messages even after the device removal.
This leads to use after free. Also the channel resources are not freed.
Fix this by checking the rx_chan correctly.

Fixes: ffdbae28d9d1a ("drivers: soc: xilinx: Use mailbox IPI callback")
Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20260320060445.1541017-1-ptsm@linux.microsoft.com
drivers/soc/xilinx/zynqmp_power.c

index 9dd938bd01d840ab900ad5f2a47b5496db7684d5..370e61ac47d88f8d6e21cf3f3c4680965a9b2668 100644 (file)
@@ -389,8 +389,10 @@ static void zynqmp_pm_remove(struct platform_device *pdev)
 {
        sysfs_remove_file(&pdev->dev.kobj, &dev_attr_suspend_mode.attr);
 
-       if (!rx_chan)
+       if (rx_chan) {
                mbox_free_channel(rx_chan);
+               rx_chan = NULL;
+       }
 }
 
 static const struct of_device_id pm_of_match[] = {