ALSA: usb-audio: qcom: Introduce QC USB SND offloading support
Hello Wesley Cheng,
Commit 326bbc348298 ("ALSA: usb-audio: qcom: Introduce QC USB SND offloading support") from Apr 9, 2025 (linux-next), leads to the following Smatch static checker warning:
sound/usb/qcom/qc_audio_offload.c:762 qmi_stop_session()
error: we previously assumed 'subs' could be null (see line 761)
sound/usb/qcom/qc_audio_offload.c
737 static void qmi_stop_session(void)
738 {
739 struct snd_usb_substream *subs;
740 struct usb_host_endpoint *ep;
741 struct snd_usb_audio *chip;
742 struct intf_info *info;
743 int pcm_card_num;
744 int if_idx;
745 int idx;
746
747 mutex_lock(&qdev_mutex);
748 /* find all active intf for set alt 0 and cleanup usb audio dev */
749 for (idx = 0; idx < SNDRV_CARDS; idx++) {
750 if (!atomic_read(&uadev[idx].in_use))
751 continue;
752
753 chip = uadev[idx].chip;
754 for (if_idx = 0; if_idx < uadev[idx].num_intf; if_idx++) {
755 if (!uadev[idx].info || !uadev[idx].info[if_idx].in_use)
756 continue;
757 info = &uadev[idx].info[if_idx];
758 pcm_card_num = info->pcm_card_num;
759 subs = find_substream(pcm_card_num, info->pcm_dev_num,
760 info->direction);
761 if (!subs || !chip || atomic_read(&chip->shutdown)) {
^^^^Check for NULL
--> 762 dev_err(&subs->dev->dev,
^^^^^^^^^^^^^^^
Unchecked derefrence
763 "no sub for c#%u dev#%u dir%u\n",
764 info->pcm_card_num,
765 info->pcm_dev_num,
766 info->direction);
767 continue;regards,
dan carpenter