From: jsg Date: Mon, 19 Aug 2024 08:22:30 +0000 (+0000) Subject: avoid NULL deref if malloc fails X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9c5773df0ce0f60eb6054a21b231f281f1ad7835;p=openbsd avoid NULL deref if malloc fails ok stsp@ --- diff --git a/sys/dev/ic/qwx.c b/sys/dev/ic/qwx.c index 684210a993d..bd017454ae6 100644 --- a/sys/dev/ic/qwx.c +++ b/sys/dev/ic/qwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qwx.c,v 1.65 2024/08/18 07:34:45 stsp Exp $ */ +/* $OpenBSD: qwx.c,v 1.66 2024/08/19 08:22:30 jsg Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -173,7 +173,8 @@ qwx_node_alloc(struct ieee80211com *ic) struct qwx_node *nq; nq = malloc(sizeof(struct qwx_node), M_DEVBUF, M_NOWAIT | M_ZERO); - nq->peer.peer_id = HAL_INVALID_PEERID; + if (nq != NULL) + nq->peer.peer_id = HAL_INVALID_PEERID; return (struct ieee80211_node *)nq; } diff --git a/sys/dev/ic/qwz.c b/sys/dev/ic/qwz.c index 063631bc0ac..0de2e61e5f0 100644 --- a/sys/dev/ic/qwz.c +++ b/sys/dev/ic/qwz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qwz.c,v 1.4 2024/08/16 00:26:54 patrick Exp $ */ +/* $OpenBSD: qwz.c,v 1.5 2024/08/19 08:22:30 jsg Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -172,7 +172,8 @@ qwz_node_alloc(struct ieee80211com *ic) struct qwz_node *nq; nq = malloc(sizeof(struct qwz_node), M_DEVBUF, M_NOWAIT | M_ZERO); - nq->peer.peer_id = HAL_INVALID_PEERID; + if (nq != NULL) + nq->peer.peer_id = HAL_INVALID_PEERID; return (struct ieee80211_node *)nq; }