From b8dc7befe550998daf7d1cc53cdb4cafbf337ba3 Mon Sep 17 00:00:00 2001 From: bluhm Date: Mon, 16 May 2022 13:31:19 +0000 Subject: [PATCH] pfi_kif_alloc() may be called with M_NOWAIT. Add NULL check to handle malloc(9) failure. from markus@; OK sashan@ --- sys/net/pf_if.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c index e5dd4ad963b..dd1b11d44af 100644 --- a/sys/net/pf_if.c +++ b/sys/net/pf_if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_if.c,v 1.104 2022/04/29 09:55:43 mbuhl Exp $ */ +/* $OpenBSD: pf_if.c,v 1.105 2022/05/16 13:31:19 bluhm Exp $ */ /* * Copyright 2005 Henning Brauer @@ -93,6 +93,8 @@ pfi_kif_alloc(const char *kif_name, int mflags) struct pfi_kif *kif; kif = malloc(sizeof(*pfi_all), PFI_MTYPE, mflags|M_ZERO); + if (kif == NULL) + return (NULL); strlcpy(kif->pfik_name, kif_name, sizeof(kif->pfik_name)); kif->pfik_tzero = gettime(); TAILQ_INIT(&kif->pfik_dynaddrs); -- 2.20.1