Skip to content

Commit

Permalink
MeTee: Windows: initilaize variables
Browse files Browse the repository at this point in the history
Initialize variables to make error paths work.

Signed-off-by: Alexander Usyskin <[email protected]>
  • Loading branch information
ausyskin committed Feb 26, 2024
1 parent 26e2bd4 commit 6ab9ccc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Windows/metee_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEESTATUS TEEAPI TeeInitFull(IN OUT PTEEHANDLE handle, IN const GUID* guid,
TEESTATUS status;
error_status_t res;
char devicePath[MAX_PATH] = {0};
const char *devicePathP;
const char *devicePathP = NULL;
HANDLE deviceHandle = INVALID_HANDLE_VALUE;
struct METEE_WIN_IMPL* impl_handle = NULL;

Expand Down Expand Up @@ -127,18 +127,19 @@ TEESTATUS TEEAPI TeeInitFull(IN OUT PTEEHANDLE handle, IN const GUID* guid,
ERRPRINT(handle, "Can't allocate memory for internal struct");
goto Cleanup;
}
impl_handle->device_path = NULL;

switch (device.type) {
case TEE_DEVICE_TYPE_NONE:
case TEE_DEVICE_TYPE_PATH:
case TEE_DEVICE_TYPE_GUID:
status = __CreateFile(handle, devicePath, &deviceHandle);
status = __CreateFile(handle, devicePathP, &deviceHandle);
if (status != TEE_SUCCESS) {
goto Cleanup;
}
impl_handle->handle = deviceHandle;
impl_handle->close_on_exit = true;
impl_handle->device_path = _strdup(devicePath);
impl_handle->device_path = _strdup(devicePathP);
if (impl_handle->device_path == NULL) {
ERRPRINT(handle, "Error in in device path copy\n");
status = TEE_UNABLE_TO_COMPLETE_OPERATION;
Expand Down

0 comments on commit 6ab9ccc

Please sign in to comment.