public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [bug report] ALSA: mixart: Use nonatomic PCM ops
Date: Wed, 18 Nov 2020 16:52:12 +0300	[thread overview]
Message-ID: <20201118135212.GA373539@mwanda> (raw)

[ This bug predates git but my email script just uses `git blame -w`.
  -dan ]

Hello Takashi Iwai,

The patch 8d3a8b5cb57d: "ALSA: mixart: Use nonatomic PCM ops" from
Sep 10, 2014, leads to the following static checker warning:

	sound/pci/mixart/mixart_core.c:73 get_msg()
	warn: called with lock held.  '&mgr->msg_lock'

sound/pci/mixart/mixart_core.c
    63  static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
    64                     u32 msg_frame_address )
    65  {
    66          u32  headptr;
    67          u32  size;
    68          int  err;
    69  #ifndef __BIG_ENDIAN
    70          unsigned int i;
    71  #endif
    72  
    73          mutex_lock(&mgr->msg_lock);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
Smatch says that get_msg() is called with this lock already held.

    74          err = 0;
    75  
    76          /* copy message descriptor from miXart to driver */
    77          size                =  readl_be(MIXART_MEM(mgr, msg_frame_address));       /* size of descriptor + response */
    78          resp->message_id    =  readl_be(MIXART_MEM(mgr, msg_frame_address + 4));   /* dwMessageID */


[ snip ]

   419  irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id)
   420  {
   421          struct mixart_mgr *mgr = dev_id;
   422          int err;
   423          struct mixart_msg resp;
   424          u32 msg;
   425  
   426          mutex_lock(&mgr->lock);
                ^^^^^^^^^^^^^^^^^^^^^^
We are holding the lock

   427          /* process interrupt */
   428          while (retrieve_msg_frame(mgr, &msg)) {
   429  
   430                  switch (msg & MSG_TYPE_MASK) {
   431                  case MSG_TYPE_COMMAND:
   432                          resp.message_id = 0;
   433                          resp.data = mixart_msg_data;
   434                          resp.size = sizeof(mixart_msg_data);
   435                          err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK);
                                      ^^^^^^^^^^^
When get_msg() is called on this path.

   436                          if( err < 0 ) {
   437                                  dev_err(&mgr->pci->dev,
   438                                          "interrupt: error(%d) reading mf %x\n",
   439                                          err, msg);
   440                                  break;
   441                          }
   442  
   443                          if(resp.message_id == MSG_SERVICES_TIMER_NOTIFY) {

regards,
dan carpenter

                 reply	other threads:[~2020-11-18 13:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201118135212.GA373539@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox