Skip to content

Commit

Permalink
nvmecontrol: Free array of I/O queue pairs on failure to handoff
Browse files Browse the repository at this point in the history
This is harmless but cleaner.

Reported by:	Coverity Scan
CID:	 	1545041,1545049
Sponsored by:	Chelsio Communications
  • Loading branch information
bsdjhb committed May 10, 2024
1 parent 1f029b8 commit 0ac468c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sbin/nvmecontrol/connect.c
Expand Up @@ -84,12 +84,15 @@ connect_nvm_controller(enum nvmf_trtype trtype, int adrfam, const char *address,
error = connect_nvm_queues(&aparams, trtype, adrfam, address, port,
cntlid, subnqn, opt.hostnqn, opt.kato, &admin, io,
opt.num_io_queues, opt.queue_size, &cdata);
if (error != 0)
if (error != 0) {
free(io);
return (error);
}

error = nvmf_handoff_host(admin, opt.num_io_queues, io, &cdata);
if (error != 0) {
warnc(error, "Failed to handoff queues to kernel");
free(io);
return (EX_IOERR);
}
free(io);
Expand Down
5 changes: 4 additions & 1 deletion sbin/nvmecontrol/reconnect.c
Expand Up @@ -85,12 +85,15 @@ reconnect_nvm_controller(int fd, enum nvmf_trtype trtype, int adrfam,
error = connect_nvm_queues(&aparams, trtype, adrfam, address, port,
rparams.cntlid, rparams.subnqn, opt.hostnqn, opt.kato, &admin, io,
opt.num_io_queues, opt.queue_size, &cdata);
if (error != 0)
if (error != 0) {
free(io);
return (error);
}

error = nvmf_reconnect_host(fd, admin, opt.num_io_queues, io, &cdata);
if (error != 0) {
warnc(error, "Failed to handoff queues to kernel");
free(io);
return (EX_IOERR);
}
free(io);
Expand Down

0 comments on commit 0ac468c

Please sign in to comment.