diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-02-02 11:18:58 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-02-02 11:18:58 +0000 |
commit | 0bf594d9542eefcaa6d8198c743aaf6cda9cdac5 (patch) | |
tree | af1b37a7c86a9b34fa7aa68b37d2a1fa8be796f0 /usr.bin/sndiod/dev.c | |
parent | e713263fb635163ee7f7e773489fa2dc847ce4c1 (diff) |
Fix use-after-free in dev_abort()
Fixes crash that can occur when an usb device is unplugged, found by edd@
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r-- | usr.bin/sndiod/dev.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 176e8b17e79..6e2e1a6fa6e 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.89 2021/01/29 11:38:23 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.90 2021/02/02 11:18:57 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1281,12 +1281,12 @@ dev_abort(struct dev *d) d->slot_list = NULL; for (c = ctlslot_array, i = DEV_NCTLSLOT; i > 0; i--, c++) { + if (c->ops == NULL) + continue; if (c->opt->dev != d) continue; - if (c->ops) { - c->ops->exit(c->arg); - c->ops = NULL; - } + c->ops->exit(c->arg); + c->ops = NULL; } midi_abort(d->midi); |