[bug report] media: sound/usb: Use Media Controller API to share media resources
Dan Carpenter
dan.carpenter at oracle.com
Wed Jun 2 14:59:41 CEST 2021
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
More information about the Alsa-devel
mailing list