Skip to content

Commit c33059a

Browse files
committed
ioctl: use dummy passthru command
The ioctl probing is triggering a valgrind report. Let's pass in a empty command which will return a status code (0x4101) if the ioctl is supported. ==143223== Syscall param ioctl(generic) points to unaddressable byte(s) ==143223== at 0x49BE36D: ioctl (ioctl.c:36) ==143223== by 0x48644AB: __nvme_transport_handle_open_direct (linux.c:110) ==143223== by 0x48646C1: nvme_open (linux.c:169) ==143223== by 0x40DDBD: get_transport_handle (nvme.c:366) ==143223== by 0x40DF00: parse_and_open (nvme.c:404) ==143223== by 0x42F4BC: submit_io (nvme.c:8237) ==143223== by 0x430268: read_cmd (nvme.c:8470) ==143223== by 0x45CDD6: handle_plugin (plugin.c:190) ==143223== by 0x43ACF2: main (nvme.c:11032) Signed-off-by: Daniel Wagner <[email protected]>
1 parent 3c47aa7 commit c33059a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libnvme/src/nvme/linux.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl,
7676

7777
static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl, const char *devname)
7878
{
79+
struct nvme_passthru_cmd dummy = { 0 };
7980
_cleanup_free_ char *path = NULL;
8081
char *name = basename(devname);
8182
int ret, id, ns;
@@ -107,8 +108,8 @@ static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl
107108
return -EINVAL;
108109
}
109110

110-
ret = ioctl(hdl->fd, NVME_IOCTL_ADMIN64_CMD, NULL);
111-
if (ret == -1 && errno != ENOTTY)
111+
ret = ioctl(hdl->fd, NVME_IOCTL_ADMIN64_CMD, &dummy);
112+
if (ret > 0)
112113
hdl->ioctl64 = true;
113114

114115
return 0;

0 commit comments

Comments
 (0)