aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2026-07-21 06:33:38 +0000
committerToomas Soome <tsoome@FreeBSD.org>2026-07-21 06:33:38 +0000
commita0486017c2a453ce5e8b6e678a14e7d5577c1300 (patch)
tree4bddea248e1a91a4e5c0eff05b82e3bf9f258da8
parenteca7b25c101a240472c4c274e725bc294284c827 (diff)
bhyve: check upper bounds for value from qsz
The max_qentries in pci_nvme_softc is uint16_t and too large int may get truncated to invalid value. While there, use local declarations for val. Suggested by: Bill Sommerfeld Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D58293
-rw-r--r--usr.sbin/bhyve/pci_nvme.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 3656ee7a8d65..b2b9f0ff88a8 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -3185,7 +3185,7 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
value = get_config_value_node(nvl, "qsz");
if (value != NULL) {
val = atoi(value);
- if (val <= 0) {
+ if (val <= 0 || val > UINT16_MAX) {
EPRINTLN("nvme: Invalid qsz option %d", val);
return (-1);
}