Skip to content

Commit

Permalink
Fix coverity issues CID 271877, CID 271875 (Xilinx#6814)
Browse files Browse the repository at this point in the history
Signed-off-by: Rajkumar Rampelli <[email protected]>

Co-authored-by: Rajkumar Rampelli <[email protected]>
  • Loading branch information
rajkumar-xilinx and Rajkumar Rampelli authored Jun 28, 2022
1 parent 29b3d5b commit 961619a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/runtime_src/core/include/xgq_cmd_vmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum xgq_cmd_sensor_page_id {
XGQ_CMD_SENSOR_SID_POWER = 0x5,
XGQ_CMD_SENSOR_SID_QSFP = 0x6,
XGQ_CMD_SENSOR_SID_ALL = 0x7,
XGQ_CMD_SENSOR_SID_MAX = 0x8,
};

/**
Expand Down
17 changes: 11 additions & 6 deletions src/runtime_src/core/pcie/driver/linux/xocl/subdev/hwmon_sdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ static int sdr_get_id(int repo_type)
int id = 0;

switch(repo_type) {
case SDR_TYPE_GET_SIZE:
id = XGQ_CMD_SENSOR_SID_GET_SIZE;
break;
case SDR_TYPE_BDINFO:
id = XGQ_CMD_SENSOR_SID_BDINFO;
break;
Expand Down Expand Up @@ -546,22 +549,24 @@ static int parse_single_sdr_info(struct xocl_hwmon_sdm *sdm, char *in_buf,
uint32_t sdr_index = (data_args >> 16) & 0xFFF;
uint8_t field_id = (data_args >> 8) & 0xF;
uint8_t completion_code, repo_type, val_len;
int buf_index;
int buf_index, rcvd_rid;

completion_code = in_buf[SDR_COMPLETE_IDX];
if(completion_code != SDR_CODE_OP_SUCCESS) {
dump_error_message(sdm, completion_code);
return -EINVAL;
}

repo_type = in_buf[SDR_REPO_IDX];
repo_id = sdr_get_id(repo_type);
if (repo_id < 0) {
xocl_err(&sdm->pdev->dev, "SDR Responce has INVALID REPO TYPE: %d", repo_type);
buf_index = SDR_REPO_IDX;
repo_type = in_buf[buf_index];
rcvd_rid = sdr_get_id(repo_type);
if ((rcvd_rid < 0) || (rcvd_rid != repo_id) ||
(repo_id >= XGQ_CMD_SENSOR_SID_MAX)) {
xocl_err(&sdm->pdev->dev, "SDR Responce has invalid REPO TYPE: %d", repo_type);
return -EINVAL;
}

buf_index = SDR_REPO_IDX + 1;
buf_index = buf_index + 1;
val_len = in_buf[buf_index];

buf_index = buf_index + 1;
Expand Down

0 comments on commit 961619a

Please sign in to comment.