From 802c227e3a1d7fd4bb043494b5840376a5592cb7 Mon Sep 17 00:00:00 2001 From: dv Date: Sun, 29 Aug 2021 11:41:27 +0000 Subject: [PATCH] check for null vioblk info If {c,m}alloc fail, info could be NULL and result in NULL deref. Reported by Ilja van Sprundel. ok mlarkin@ --- usr.sbin/vmd/virtio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index 30580c0f5bc..8150047b13f 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.94 2021/08/29 11:14:27 dv Exp $ */ +/* $OpenBSD: virtio.c,v 1.95 2021/08/29 11:41:27 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -521,6 +521,11 @@ vioblk_notifyq(struct vioblk_dev *dev) info = vioblk_start_read(dev, cmd.sector + secbias, secdata_desc->len); + if (info == NULL) { + log_warnx("vioblk: can't start read"); + goto out; + } + /* read the data, use current data descriptor */ secdata = vioblk_finish_read(info); if (secdata == NULL) { -- 2.20.1