Code Review
/
deb_dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
New upstream version 17.11.4
[deb_dpdk.git]
/
lib
/
librte_metrics
/
rte_metrics.c
diff --git
a/lib/librte_metrics/rte_metrics.c
b/lib/librte_metrics/rte_metrics.c
index
d940400
..
dc63446
100644
(file)
--- a/
lib/librte_metrics/rte_metrics.c
+++ b/
lib/librte_metrics/rte_metrics.c
@@
-124,6
+124,9
@@
rte_metrics_reg_names(const char * const *names, uint16_t cnt_names)
/* Some sanity checks */
if (cnt_names < 1 || names == NULL)
return -EINVAL;
/* Some sanity checks */
if (cnt_names < 1 || names == NULL)
return -EINVAL;
+ for (idx_name = 0; idx_name < cnt_names; idx_name++)
+ if (names[idx_name] == NULL)
+ return -EINVAL;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
if (memzone == NULL)
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
if (memzone == NULL)
@@
-190,6
+193,11
@@
rte_metrics_update_values(int port_id,
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
+
+ if (key >= stats->cnt_stats) {
+ rte_spinlock_unlock(&stats->lock);
+ return -EINVAL;
+ }
idx_metric = key;
cnt_setsize = 1;
while (idx_metric < stats->cnt_stats) {
idx_metric = key;
cnt_setsize = 1;
while (idx_metric < stats->cnt_stats) {
@@
-231,9
+239,8
@@
rte_metrics_get_names(struct rte_metric_name *names,
int return_value;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
int return_value;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
- /* If not allocated, fail silently */
if (memzone == NULL)
if (memzone == NULL)
- return
0
;
+ return
-EIO
;
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
@@
-269,9
+276,9
@@
rte_metrics_get_values(int port_id,
return -EINVAL;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
return -EINVAL;
memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
- /* If not allocated, fail silently */
if (memzone == NULL)
if (memzone == NULL)
- return 0;
+ return -EIO;
+
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);
stats = memzone->addr;
rte_spinlock_lock(&stats->lock);