···178178 return -ENOMEM;179179180180 err = snd_card_init(card, parent, idx, xid, module, extra_size);181181- if (err < 0) {182182- kfree(card);183183- return err;184184- }181181+ if (err < 0)182182+ return err; /* card is freed by error handler */185183186184 *card_ret = card;187185 return 0;···231233 card->managed = true;232234 err = snd_card_init(card, parent, idx, xid, module, extra_size);233235 if (err < 0) {234234- devres_free(card);236236+ devres_free(card); /* in managed mode, we need to free manually */235237 return err;236238 }237239···295297 mutex_unlock(&snd_card_mutex);296298 dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n",297299 idx, snd_ecards_limit - 1, err);300300+ if (!card->managed)301301+ kfree(card); /* manually free here, as no destructor called */298302 return err;299303 }300304 set_bit(idx, snd_cards_lock); /* lock it */
+14-9
sound/usb/endpoint.c
···758758 * The endpoint needs to be closed via snd_usb_endpoint_close() later.759759 *760760 * Note that this function doesn't configure the endpoint. The substream761761- * needs to set it up later via snd_usb_endpoint_set_params() and762762- * snd_usb_endpoint_prepare().761761+ * needs to set it up later via snd_usb_endpoint_configure().763762 */764763struct snd_usb_endpoint *765764snd_usb_endpoint_open(struct snd_usb_audio *chip,···12921293/*12931294 * snd_usb_endpoint_set_params: configure an snd_usb_endpoint12941295 *12951295- * It's called either from hw_params callback.12961296 * Determine the number of URBs to be used on this endpoint.12971297 * An endpoint must be configured before it can be started.12981298 * An endpoint that is already running can not be reconfigured.12991299 */13001300-int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,13011301- struct snd_usb_endpoint *ep)13001300+static int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,13011301+ struct snd_usb_endpoint *ep)13021302{13031303 const struct audioformat *fmt = ep->cur_audiofmt;13041304 int err;···13801382}1381138313821384/*13831383- * snd_usb_endpoint_prepare: Prepare the endpoint13851385+ * snd_usb_endpoint_configure: Configure the endpoint13841386 *13851387 * This function sets up the EP to be fully usable state.13861386- * It's called either from prepare callback.13881388+ * It's called either from hw_params or prepare callback.13871389 * The function checks need_setup flag, and performs nothing unless needed,13881390 * so it's safe to call this multiple times.13891391 *13901392 * This returns zero if unchanged, 1 if the configuration has changed,13911393 * or a negative error code.13921394 */13931393-int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,13941394- struct snd_usb_endpoint *ep)13951395+int snd_usb_endpoint_configure(struct snd_usb_audio *chip,13961396+ struct snd_usb_endpoint *ep)13951397{13961398 bool iface_first;13971399 int err = 0;···14121414 if (err < 0)14131415 goto unlock;14141416 }14171417+ err = snd_usb_endpoint_set_params(chip, ep);14181418+ if (err < 0)14191419+ goto unlock;14151420 goto done;14161421 }14171422···14391438 goto unlock;1440143914411440 err = init_sample_rate(chip, ep);14411441+ if (err < 0)14421442+ goto unlock;14431443+14441444+ err = snd_usb_endpoint_set_params(chip, ep);14421445 if (err < 0)14431446 goto unlock;14441447