Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: ipc4: check return value #4577

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

bardliao
Copy link
Collaborator

@bardliao bardliao commented Sep 7, 2023

snd_sof_ipc_msg_data could return error.

snd_sof_ipc_msg_data(sdev, NULL, ipc4_msg->data_ptr, ipc4_msg->data_size);
err = snd_sof_ipc_msg_data(sdev, NULL, ipc4_msg->data_ptr, ipc4_msg->data_size);
if (err < 0) {
dev_warn(sdev->dev, "failed to read IPC reply data: %d\n", err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be actually an error here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the text is incorrect, this is not a reply, this is a notification.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the text is incorrect, this is not a reply, this is a notification.

ack

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be actually an error here?

I changed it to dev_err. To be honestly, I am not sure what is the impact if we don't get the data.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao, it is an error for sure. Some messages must have data in payload, like the RESOURCE_EVENT and the will be added MODULE_NOTIFICATION.

What I'm not sure is that will it ever happen? I think not, but have not checked it.

}

sof_ipc4_log_header(sdev->dev, "ipc rx done ", ipc4_msg, true);

out:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this applies at all?
We are now dumping the payload if data_size is not NULL and we might dump invalid data if the snd_sof_ipc_msg_data() failed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this applies at all? We are now dumping the payload if data_size is not NULL and we might dump invalid data if the snd_sof_ipc_msg_data() failed.

Yes, it didn't conflict. But, yes, it might dump invalid data if the snd_sof_ipc_msg_data() failed. So, return err immediately.

@@ -631,11 +631,15 @@ static void sof_ipc4_rx_msg(struct snd_sof_dev *sdev)
return;

ipc4_msg->data_size = data_size;
snd_sof_ipc_msg_data(sdev, NULL, ipc4_msg->data_ptr, ipc4_msg->data_size);
err = snd_sof_ipc_msg_data(sdev, NULL, ipc4_msg->data_ptr, ipc4_msg->data_size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and for the record: this cannot fail in this context as the second parameter is NULL.

err = snd_sof_ipc_msg_data(sdev, NULL, ipc4_msg->data_ptr, ipc4_msg->data_size);
if (err < 0) {
dev_err(sdev->dev, "failed to read IPC notification data: %d\n", err);
return err;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need to do the cleanup for the allocated buffer...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need to do the cleanup for the allocated buffer...

fixed

snd_sof_ipc_msg_data could return error.

Signed-off-by: Bard Liao <[email protected]>
@plbossart plbossart merged commit 776cbce into thesofproject:topic/sof-dev Nov 10, 2023
13 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.

3 participants