From b48c608386bc54ce249eb1b031894edcf08d79b3 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 9 May 2016 12:24:39 +0000 Subject: [PATCH] Check malloc succeeded in pic_create, with M_NOWAIT it may return NULL. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/kern/subr_intr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c index 98e8e387106b..9b92e7314f60 100644 --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -871,6 +871,10 @@ pic_create(device_t dev, intptr_t xref) return (pic); } pic = malloc(sizeof(*pic), M_INTRNG, M_NOWAIT | M_ZERO); + if (pic == NULL) { + mtx_unlock(&pic_list_lock); + return (NULL); + } pic->pic_xref = xref; pic->pic_dev = dev; SLIST_INSERT_HEAD(&pic_list, pic, pic_next);