Skip to content

solidigm: fix unchecked return value in ilog_dump_pel() - #3972

Open
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-solidigm-internal-logs-unchecked-return
Open

solidigm: fix unchecked return value in ilog_dump_pel()#3972
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-solidigm-internal-logs-unchecked-return

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

The ilog_dump_pel() function calls nvme_get_log_persistent_event() with NVME_PEVENT_LOG_RELEASE_CTX as the final step to release the persistent event log context on the device. The return value of this call was not checked.

If the release call fails, the device-side context is left open. Any subsequent attempt to establish a new context may fail or behave unexpectedly.

Use a goto to ensure the release call is always reached and its return value is captured and returned to the caller.

The ilog_dump_pel() function calls nvme_get_log_persistent_event()
with NVME_PEVENT_LOG_RELEASE_CTX as the final step to release the
persistent event log context on the device. The return value of
this call was not checked.

If the release call fails, the device-side context is left open.
Any subsequent attempt to establish a new context may fail or
behave unexpectedly.

Use a goto to ensure the release call is always reached and its
return value is captured and returned to the caller.

Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
@@ -819,16 +808,18 @@ static int ilog_dump_pel(struct libnvme_transport_handle *hdl, struct ilog *ilog
err = nvme_get_log_persistent_event(hdl, NVME_PEVENT_LOG_READ,
pevent_log_full, lp.buffer_size);
if (err)
return err;
goto out;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary because the err label just does a return err?


ilog->count++;

err = log_save(&lp, ilog->cfg->out_dir, "log_pages", "lid_0x0d_lsp_0x00_lsi_0x0000.bin",
pevent_log_full, lp.buffer_size);
if (err)
goto out;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, can't this just be a return err?

nvme_get_log_persistent_event(hdl, NVME_PEVENT_LOG_RELEASE_CTX,
pevent, sizeof(*pevent));

err = nvme_get_log_persistent_event(hdl, NVME_PEVENT_LOG_RELEASE_CTX,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this could be just return nvme_get_log_persistentent_event, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants