summaryrefslogtreecommitdiff
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-09-20 14:43:56 +0300
committerTakashi Iwai <tiwai@suse.de>2022-09-20 14:43:56 +0300
commit8e3392d340a189619aa701cd5d3b613cf0ce91f0 (patch)
tree97cf9171e7de4f00b34d670db5a9136379e8944e /sound/core
parent01a72aefbacca4d6e169caa776c87d3c1f6faf4a (diff)
parent79764ec772bc1346441ae1c4b1f3bd1991d634e8 (diff)
downloadlinux-8e3392d340a189619aa701cd5d3b613cf0ce91f0.tar.xz
Merge branch 'for-linus' into for-next
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/init.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index 193dae361fac..5377f94eb211 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -178,10 +178,8 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
return -ENOMEM;
err = snd_card_init(card, parent, idx, xid, module, extra_size);
- if (err < 0) {
- kfree(card);
- return err;
- }
+ if (err < 0)
+ return err; /* card is freed by error handler */
*card_ret = card;
return 0;
@@ -233,7 +231,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid,
card->managed = true;
err = snd_card_init(card, parent, idx, xid, module, extra_size);
if (err < 0) {
- devres_free(card);
+ devres_free(card); /* in managed mode, we need to free manually */
return err;
}
@@ -297,6 +295,8 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
mutex_unlock(&snd_card_mutex);
dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n",
idx, snd_ecards_limit - 1, err);
+ if (!card->managed)
+ kfree(card); /* manually free here, as no destructor called */
return err;
}
set_bit(idx, snd_cards_lock); /* lock it */