sndiod: fix slot leak when device mode doesn't match slot mode

This commit is contained in:
Alexandre Ratchov 2017-11-23 07:13:49 +01:00
parent 3d6b602fe9
commit 8b24905d2c
1 changed files with 8 additions and 8 deletions

View File

@ -1515,19 +1515,19 @@ slot_new(struct dev *d, char *who, struct slotops *ops, void *arg, int mode)
found:
if (!dev_ref(d))
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->ops = ops;
s->arg = arg;
s->pstate = SLOT_INIT;
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;
aparams_init(&s->par);
if (s->mode & MODE_PLAY) {