Skip to contentSkip to conversation

ASoC: SOF: amd: Use AMD_NODE

bug report Dan Carpenter 1 participant 1 message May 11 Sound

lore
Share & tools
lore
#0 lore raw

Hello Mario Limonciello,

Commit f120cf33d232 ("ASoC: SOF: amd: Use AMD_NODE") from Feb 17, 2025 (linux-next), leads to the following Smatch static checker warning:

	sound/soc/sof/amd/acp.c:232 psp_send_cmd()
	warn: kernel error codes cast to unsigned 'data'

sound/soc/sof/amd/acp.c

    222 static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
    223 {
    224         struct snd_sof_dev *sdev = adata->dev;
    225         int ret;
    226         u32 data;
    227 
    228         if (!cmd)
    229                 return -EINVAL;
    230 
    231         /* Get a non-zero Doorbell value from PSP */
--> 232         ret = read_poll_timeout(smn_read_register, data, data > 0, MBOX_DELAY_US,
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The smn_read_register() returns negative error codes or positive values on success. We're storing the return in data and testing data > 0 to see if it succeeds. But since data is unsigned then negative error codes are treated as success.

    233                                 ACP_PSP_TIMEOUT_US, false, MP0_C2PMSG_73_REG);
    234 
    235         if (ret) {
    236                 dev_err(sdev->dev, "Failed to get Doorbell from MBOX %x\n", MP0_C2PMSG_73_REG);
    237                 return ret;
    238         }
    239 
    240         /* Check if PSP is ready for new command */
    241         ret = psp_mbox_ready(adata, 0);
    242         if (ret)
    243                 return ret;
    244 

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter