From: Dan Carpenter <dan.carpenter@linaro.org>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: linux-sound@vger.kernel.org
Subject: [bug report] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support
Date: Tue, 15 Apr 2025 13:47:03 +0300 [thread overview]
Message-ID: <Z_45JyNuBhlwApX_@stanley.mountain> (raw)
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:785 qmi_stop_session()
error: we previously assumed 'chip' 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;
We should check if chip is NULL here
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)) {
^^^^
Instead of here.
762 dev_err(&subs->dev->dev,
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;
768 }
769 /* Release XHCI endpoints */
770 if (info->data_ep_pipe)
771 ep = usb_pipe_endpoint(uadev[pcm_card_num].udev,
772 info->data_ep_pipe);
773 xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, ep);
774
775 if (info->sync_ep_pipe)
776 ep = usb_pipe_endpoint(uadev[pcm_card_num].udev,
777 info->sync_ep_pipe);
778 xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, ep);
779
780 disable_audio_stream(subs);
781 }
782 atomic_set(&uadev[idx].in_use, 0);
783 mutex_lock(&chip->mutex);
^^^^^
If it is NULL this will crash.
784 uaudio_dev_cleanup(&uadev[idx]);
--> 785 mutex_unlock(&chip->mutex);
786 }
787 mutex_unlock(&qdev_mutex);
788 }
regards,
dan carpenter
next reply other threads:[~2025-04-15 10:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 10:47 Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-04-15 10:46 [bug report] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Dan Carpenter
2025-04-15 10:46 Dan Carpenter
2025-04-15 10:45 Dan Carpenter
2025-04-15 10:27 Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z_45JyNuBhlwApX_@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-sound@vger.kernel.org \
--cc=quic_wcheng@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.