aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2020-12-11 17:07:47 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2020-12-21 19:11:05 -0500
commit78bc32cbd721aaf6d493ecc70f09fc8ca125ac6f (patch)
tree64654de01d64bc50ca7424cde0577a588787b95b
parente30b406e9f1ce99658c542970dae60e2ed8a913e (diff)
downloadkernel-shark-78bc32cbd721aaf6d493ecc70f09fc8ca125ac6f.tar.gz
kernel-shark: Protect ksmodel_set_in_range_bining()
Handle the case when the number of bins is zero or negative. Link: https://lore.kernel.org/linux-trace-devel/20201211150756.577366-24-y.karadz@gmail.com Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--src/libkshark-model.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libkshark-model.c b/src/libkshark-model.c
index 2301b069..44f829d6 100644
--- a/src/libkshark-model.c
+++ b/src/libkshark-model.c
@@ -97,8 +97,19 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
int64_t corrected_range, delta_range, range = max - min;
struct kshark_entry *last;
+ if (n <= 0) {
+ histo->n_bins = histo->bin_size = 0;
+ histo->min = min;
+ histo->max = max;
+
+ free(histo->bin_count);
+ free(histo->map);
+
+ return;
+ }
+
/* The size of the bin must be >= 1, hence the range must be >= n. */
- if (n == 0 || range < n) {
+ if (range < n) {
range = n;
max = min + n;
}