From 7eedd813a5d029489a0016230009c45620d774fe Mon Sep 17 00:00:00 2001 From: Martin George Date: Wed, 10 Dec 2025 13:09:50 +0530 Subject: [PATCH] ioctl: avoid segfaults due to potential NULL pointer dereferencing Add guardrails to avoid segfaults due to potential NULL pointer dereferencing in nvme_submit_passthru64() and nvme_submit_passthru32() functions. Signed-off-by: Martin George --- libnvme/src/nvme/ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libnvme/src/nvme/ioctl.c b/libnvme/src/nvme/ioctl.c index 818e6472bf..8b00c2448b 100644 --- a/libnvme/src/nvme/ioctl.c +++ b/libnvme/src/nvme/ioctl.c @@ -126,7 +126,7 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl, int err = 0; user_data = hdl->submit_entry(hdl, cmd); - if (hdl->ctx->dry_run) + if (hdl->ctx && hdl->ctx->dry_run) goto out; memcpy(&cmd32, cmd, offsetof(struct linux_passthru_cmd32, result)); @@ -156,7 +156,7 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl, int err = 0; user_data = hdl->submit_entry(hdl, cmd); - if (hdl->ctx->dry_run) + if (hdl->ctx && hdl->ctx->dry_run) goto out; do {