Skip to content

Commit a9fd56b

Browse files
committed
lib: fix MMIO device RMID bounds
Signed-off-by: Raghavan Kanagaraj <raghavan.kanagaraj@intel.com>
1 parent 683e08d commit a9fd56b

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

lib/mmio_monitoring.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,15 @@ get_dev_rmid_list(struct pqos_mon_poll_ctx *ctx,
383383
if (ret != PQOS_RETVAL_OK)
384384
return ret;
385385

386-
if (rmid <= max_rmid) {
387-
if (domain_id_idx >= erdt->num_dev_agents) {
388-
LOG_ERROR("Wrong domain_id_idx %d "
389-
"Dev Agents %d\n",
390-
domain_id_idx, erdt->num_dev_agents);
391-
return PQOS_RETVAL_UNAVAILABLE;
392-
}
386+
if (domain_id_idx >= erdt->num_dev_agents) {
387+
LOG_ERROR("Wrong domain_id_idx %d "
388+
"Dev Agents %d\n",
389+
domain_id_idx, erdt->num_dev_agents);
390+
return PQOS_RETVAL_UNAVAILABLE;
391+
}
393392

393+
if (rmid <= max_rmid &&
394+
rmid <= erdt->dev_agents[domain_id_idx].rmdd.max_rmids) {
394395
if (dev_rmid_list[domain_id_idx].domain_id == domain_id)
395396
dev_rmid_list[domain_id_idx].rmids[rmid] = 1;
396397
else
@@ -450,7 +451,8 @@ mmio_mon_channels_assoc_unused(struct pqos_mon_poll_ctx *ctx,
450451
erdt->dev_agents[idx].rmdd.domain_id;
451452

452453
dev_rmid_list[idx].rmids = (pqos_rmid_t *)calloc(
453-
erdt->dev_agents[idx].rmdd.max_rmids, sizeof(pqos_rmid_t));
454+
(size_t)erdt->dev_agents[idx].rmdd.max_rmids + 1,
455+
sizeof(pqos_rmid_t));
454456
if (dev_rmid_list[idx].rmids == NULL) {
455457
LOG_ERROR("Unable to allocate memory for rmids in "
456458
"dev_rmid_list idx %d\n",

0 commit comments

Comments
 (0)