Skip to content

audioreach-driver: q6apm_audio_pkt: Fix crash issue after command tim…#59

Merged
quic-aditrath merged 1 commit into
AudioReach:masterfrom
mohsRafi:Fix_ssr_crash_issue
Apr 22, 2026
Merged

audioreach-driver: q6apm_audio_pkt: Fix crash issue after command tim…#59
quic-aditrath merged 1 commit into
AudioReach:masterfrom
mohsRafi:Fix_ssr_crash_issue

Conversation

@mohsRafi
Copy link
Copy Markdown
Contributor

Fix crash issue after command timeout during SSR.

In q6apm_send_audio_cmd_sync(), the dev_err() calls on the command timeout and DSP error paths were using the 'dev' parameter passed into the function. During SSR, this device pointer may no longer be valid, leading to a NULL pointer dereference or use-after-free. Fix this by switching to &g_apm->adev->dev, which refers to the stable global APM device and remains valid across SSR events.

In audio_pkt_release(), the audpkt_dev pointer was being obtained via cdev_to_audpkt_dev(inode->i_cdev). During SSR, the inode's cdev may have already been torn down or become invalid by the time release() is called, resulting in a crash when dereferencing the pointer.

Fix this by retrieving audpkt_dev from file->private_data, which is set during audio_pkt_open() and remains valid for the lifetime of the open file descriptor. Additionally, add a NULL check guard for audpkt_dev and audpkt_dev->dev at the start of the function to safely handle any edge cases where the private data may not have been properly initialized.

change Tested in Rb8 board.

…eout during SSR

Fix crash issue after command timeout during SSR.

In q6apm_send_audio_cmd_sync(), the dev_err() calls on the command
timeout and DSP error paths were using the 'dev' parameter passed
into the function. During SSR, this device pointer may no longer be
valid, leading to a NULL pointer dereference or use-after-free.
Fix this by switching to &g_apm->adev->dev, which refers to the
stable global APM device and remains valid across SSR events.

In audio_pkt_release(), the audpkt_dev pointer was being obtained
via cdev_to_audpkt_dev(inode->i_cdev). During SSR, the inode's
cdev may have already been torn down or become invalid by the time
release() is called, resulting in a crash when dereferencing the
pointer.

Fix this by retrieving audpkt_dev from file->private_data, which
is set during audio_pkt_open() and remains valid for the lifetime
of the open file descriptor. Additionally, add a NULL check guard
for audpkt_dev and audpkt_dev->dev at the start of the function to
safely handle any edge cases where the private data may not have
been properly initialized.

Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
@mohsRafi mohsRafi requested review from a team April 21, 2026 18:10
@quic-aditrath quic-aditrath merged commit bf478f8 into AudioReach:master Apr 22, 2026
12 of 14 checks passed
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.

5 participants