Subject: Coverity: ALSA: usb-audio: Error handling issues

From: coverity-bot <[email-masked]>
Date: Mon, 5 Apr 2021 11:02:16 -0700

Hello!

This is an experimental semi-automated report about issues detected by
Coverity from a scan of next-20210401 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by commits:

  Fri Mar 5 08:17:14 2010 +0100
    e5779998bf8b ("ALSA: usb-audio: refactor code")
  Thu Jun 27 21:59:49 2013 +0200
    b1ce7ba619d9 ("ALSA: usb-audio: claim autodetected PCM interfaces all at once")

Coverity reported the following:

*** CID 1475943:  Error handling issues  (CHECKED_RETURN)
/sound/usb/quirks.c: 430 in create_autodetect_quirks()
424     		    get_iface_desc(iface->altsetting)->bInterfaceClass !=
425     							USB_CLASS_VENDOR_SPEC)
426     			continue;
427
428     		err = create_autodetect_quirk(chip, iface, driver);
429     		if (err >= 0)
vvv     CID 1475943:  Error handling issues  (CHECKED_RETURN)
vvv     Calling "usb_driver_claim_interface" without checking return value (as is done elsewhere 16 out of 20 times).
430     			usb_driver_claim_interface(driver, iface, (void *)-1L);
431     	}
432
433     	return 0;
434     }
435

*** CID 1475944:  Error handling issues  (CHECKED_RETURN)
/sound/usb/card.c: 206 in snd_usb_create_stream()
200     		dev_err(&dev->dev, "low speed audio streaming not supported\n");
201     		return -EINVAL;
202     	}
203
204     	if (! snd_usb_parse_audio_interface(chip, interface)) {
205     		usb_set_interface(dev, interface, 0); /* reset the current interface */
vvv     CID 1475944:  Error handling issues  (CHECKED_RETURN)
vvv     Calling "usb_driver_claim_interface" without checking return value (as is done elsewhere 16 out of 20 times).
206     		usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
207     	}
208
209     	return 0;
210     }
211

*** CID 1475945:  Error handling issues  (CHECKED_RETURN)
/sound/usb/quirks.c: 59 in create_composite_quirk()
53     	for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
54     		iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
55     		if (!iface)
56     			continue;
57     		if (quirk->ifnum != probed_ifnum &&
58     		    !usb_interface_claimed(iface))
vvv     CID 1475945:  Error handling issues  (CHECKED_RETURN)
vvv     Calling "usb_driver_claim_interface" without checking return value (as is done elsewhere 16 out of 20 times).
59     			usb_driver_claim_interface(driver, iface, (void *)-1L);
60     	}
61
62     	return 0;
63     }
64

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <[email-masked]>
Addresses-Coverity-ID: 1475943 ("Error handling issues")
Addresses-Coverity-ID: 1475944 ("Error handling issues")
Addresses-Coverity-ID: 1475945 ("Error handling issues")
Fixes: b1ce7ba619d9 ("ALSA: usb-audio: claim autodetected PCM interfaces all at once")
Fixes: e5779998bf8b ("ALSA: usb-audio: refactor code")

Thanks for your attention!

-- 
Coverity-bot