Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

accel/qaic: Fix bootlog initialization ordering

As soon as we queue MHI buffers to receive the bootlog from the device,
we could be receiving data. Therefore all the resources needed to
process that data need to be setup prior to queuing the buffers.

We currently initialize some of the resources after queuing the buffers
which creates a race between the probe() and any data that comes back
from the device. If the uninitialized resources are accessed, we could
see page faults.

Fix the init ordering to close the race.

Fixes: 5f8df5c6def6 ("accel/qaic: Add bootlog debugfs")
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Reviewed-by: Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>
Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251007115750.332169-1-youssef.abdulrahman@oss.qualcomm.com

authored by

Jeffrey Hugo and committed by
Jeff Hugo
fd6e3855 48a71076

+3 -2
+3 -2
drivers/accel/qaic/qaic_debugfs.c
··· 218 218 if (ret) 219 219 goto destroy_workqueue; 220 220 221 + dev_set_drvdata(&mhi_dev->dev, qdev); 222 + qdev->bootlog_ch = mhi_dev; 223 + 221 224 for (i = 0; i < BOOTLOG_POOL_SIZE; i++) { 222 225 msg = devm_kzalloc(&qdev->pdev->dev, sizeof(*msg), GFP_KERNEL); 223 226 if (!msg) { ··· 236 233 goto mhi_unprepare; 237 234 } 238 235 239 - dev_set_drvdata(&mhi_dev->dev, qdev); 240 - qdev->bootlog_ch = mhi_dev; 241 236 return 0; 242 237 243 238 mhi_unprepare: