summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-08-19 08:22:31 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-08-19 08:22:31 +0000
commit0b99079d5eaa03ca2e1c3ade0e20c05b9849fc5e (patch)
tree2d523a72ec6d62516a150607e880af8156d6b719
parent38f65727e10b452b4ca8523514bee8fae5c2272a (diff)
avoid NULL deref if malloc fails
ok stsp@
-rw-r--r--sys/dev/ic/qwx.c5
-rw-r--r--sys/dev/ic/qwz.c5
2 files changed, 6 insertions, 4 deletions
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 <stsp@openbsd.org>
@@ -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 <stsp@openbsd.org>
@@ -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;
}