Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the count check to be done after the fru_write call #188

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions modules/fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@ IPMI_HANDLER(ipmi_storage_write_fru_data_cmd, NETFN_STORAGE, IPMI_WRITE_FRU_DATA
/* Write data to the FRU */
count = fru_write( id, &req->data[3], offset, req->data_len - 3);

/*
* If count == 0, it may indicate that the fru_write function
* failed somehow.
*/

if (count == 0) {
rsp->completion_code = IPMI_CC_UNSPECIFIED_ERROR;
return ;
}
/* Count written (1 based) */
rsp->data[len++] = count +1;
} else {
Expand All @@ -342,14 +351,5 @@ IPMI_HANDLER(ipmi_storage_write_fru_data_cmd, NETFN_STORAGE, IPMI_WRITE_FRU_DATA
rsp->completion_code = IPMI_CC_PARAM_OUT_OF_RANGE;
}

/*
* If count == 0, it may indicate that the fru_write function
* failed somehow.
*/

if (count == 0) {
rsp->completion_code = IPMI_CC_UNSPECIFIED_ERROR;
return ;
}
rsp->data_len = len;
}