Skip to content

Commit 7eedd81

Browse files
committed
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 <[email protected]>
1 parent a138f6e commit 7eedd81

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

libnvme/src/nvme/ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
126126
int err = 0;
127127

128128
user_data = hdl->submit_entry(hdl, cmd);
129-
if (hdl->ctx->dry_run)
129+
if (hdl->ctx && hdl->ctx->dry_run)
130130
goto out;
131131

132132
memcpy(&cmd32, cmd, offsetof(struct linux_passthru_cmd32, result));
@@ -156,7 +156,7 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
156156
int err = 0;
157157

158158
user_data = hdl->submit_entry(hdl, cmd);
159-
if (hdl->ctx->dry_run)
159+
if (hdl->ctx && hdl->ctx->dry_run)
160160
goto out;
161161

162162
do {

0 commit comments

Comments
 (0)