mirror of https://github.com/ericonr/sndio.git
sndiod: fix slot leak when device mode doesn't match slot mode
This commit is contained in:
parent
3d6b602fe9
commit
8b24905d2c
16
sndiod/dev.c
16
sndiod/dev.c
|
@ -1515,19 +1515,19 @@ slot_new(struct dev *d, char *who, struct slotops *ops, void *arg, int mode)
|
||||||
found:
|
found:
|
||||||
if (!dev_ref(d))
|
if (!dev_ref(d))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if ((mode & d->mode) != mode) {
|
||||||
|
if (log_level >= 1) {
|
||||||
|
slot_log(s);
|
||||||
|
log_puts(": requested mode not supported\n");
|
||||||
|
}
|
||||||
|
dev_unref(d);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
s->dev = d;
|
s->dev = d;
|
||||||
s->ops = ops;
|
s->ops = ops;
|
||||||
s->arg = arg;
|
s->arg = arg;
|
||||||
s->pstate = SLOT_INIT;
|
s->pstate = SLOT_INIT;
|
||||||
s->tstate = MMC_OFF;
|
s->tstate = MMC_OFF;
|
||||||
|
|
||||||
if ((mode & s->dev->mode) != mode) {
|
|
||||||
if (log_level >= 1) {
|
|
||||||
slot_log(s);
|
|
||||||
log_puts(": requested mode not supported\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
s->mode = mode;
|
s->mode = mode;
|
||||||
aparams_init(&s->par);
|
aparams_init(&s->par);
|
||||||
if (s->mode & MODE_PLAY) {
|
if (s->mode & MODE_PLAY) {
|
||||||
|
|
Loading…
Reference in New Issue