All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: shuah@kernel.org
Cc: alsa-devel@alsa-project.org
Subject: [bug report] media: sound/usb: Use Media Controller API to share media resources
Date: Wed, 2 Jun 2021 15:59:41 +0300	[thread overview]
Message-ID: <YLeAvT+R22FQ/Eyw@mwanda> (raw)

Hello Shuah Khan,

The patch 66354f18fe5f: "media: sound/usb: Use Media Controller API
to share media resources" from Apr 1, 2019, leads to the following
static checker warning:

	sound/usb/media.c:287 snd_media_device_create()
	warn: 'mdev' can also be NULL

sound/usb/media.c
   270  
   271          mdev = media_device_usb_allocate(usbdev, KBUILD_MODNAME, THIS_MODULE);
                ^^^^

If CONFIG_MEDIA_CONTROLLER is disabled then "mdev" is NULL.

   272          if (IS_ERR(mdev))
   273                  return -ENOMEM;
   274  
   275          /* save media device - avoid lookups */
   276          chip->media_dev = mdev;
   277  
   278  snd_mixer_init:
   279          /* Create media entities for mixer and control dev */
   280          ret = snd_media_mixer_init(chip);
   281          /* media_device might be registered, print error and continue */
   282          if (ret)
   283                  dev_err(&usbdev->dev,
   284                          "Couldn't create media mixer entities. Error: %d\n",
   285                          ret);
   286  
   287          if (!media_devnode_is_registered(mdev->devnode)) {
                                                 ^^^^^^^^^^^^^
dereferenced without checking here

   288                  /* dont'register if snd_media_mixer_init() failed */
   289                  if (ret)
   290                          goto create_fail;
   291  
   292                  /* register media_device */
   293                  ret = media_device_register(mdev);
   294  create_fail:
   295                  if (ret) {
   296                          snd_media_mixer_delete(chip);
   297                          media_device_delete(mdev, KBUILD_MODNAME, THIS_MODULE);
   298                          /* clear saved media_dev */
   299                          chip->media_dev = NULL;
   300                          dev_err(&usbdev->dev,
   301                                  "Couldn't register media device. Error: %d\n",
   302                                  ret);
   303                          return ret;
   304                  }
   305          }
   306  
   307          return ret;
   308  }

regards,
dan carpenter

             reply	other threads:[~2021-06-02 13:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 12:59 Dan Carpenter [this message]
2021-06-08 17:53 ` [bug report] media: sound/usb: Use Media Controller API to share media resources Shuah Khan
2021-06-08 19:03   ` Dan Carpenter
2021-06-08 19:49     ` Shuah Khan

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=YLeAvT+R22FQ/Eyw@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=shuah@kernel.org \
    /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.