From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v4 18/20] kernel-shark: Protect ksmodel_set_in_range_bining()
Date: Wed, 18 Nov 2020 16:50:01 +0200 [thread overview]
Message-ID: <20201118145003.156542-19-y.karadz@gmail.com> (raw)
In-Reply-To: <20201118145003.156542-1-y.karadz@gmail.com>
Handle the case when the number of bins is zero or negative.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
src/libkshark-model.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
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;
}
--
2.25.1
next prev parent reply other threads:[~2020-11-18 14:51 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 14:49 [PATCH v4 00/20] Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 01/20] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 02/20] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 03/20] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 04/20] kernel-shark: Introduce Data streams Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 05/20] kernel-shark: Rename static methods in libkshark Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 06/20] kernel-shark: Add basic methods for Data streams Yordan Karadzhov (VMware)
2020-11-18 22:13 ` Steven Rostedt
2020-11-19 16:01 ` Yordan Karadzhov (VMware)
2020-11-19 16:38 ` Steven Rostedt
2020-11-18 22:17 ` Steven Rostedt
2020-11-19 16:04 ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 07/20] kernel-shark: Housekeeping before implementing stream interface Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 08/20] kernel-shark: Add stream interface for trace-cmd data Yordan Karadzhov (VMware)
2020-11-19 1:11 ` Steven Rostedt
2020-11-19 16:06 ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 09/20] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 10/20] kernel-shark: Start using data streams Yordan Karadzhov (VMware)
2020-11-19 1:29 ` Steven Rostedt
2020-11-19 16:08 ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 11/20] kernel-shark: Remove dead code Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 12/20] kernel-shark: Redesign the plugin interface Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 13/20] kernel-shark: Complete the stream integration Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 14/20] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2020-11-19 2:00 ` Steven Rostedt
2020-11-19 16:14 ` Yordan Karadzhov (VMware)
2020-11-19 16:43 ` Steven Rostedt
2020-11-19 17:48 ` Yordan Karadzhov (VMware)
2020-11-19 20:43 ` Steven Rostedt
2020-11-18 14:49 ` [PATCH v4 15/20] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 16/20] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 17/20] kernel-shark: Add ksmodel_get_bin() Yordan Karadzhov (VMware)
2020-11-18 14:50 ` Yordan Karadzhov (VMware) [this message]
2020-11-18 14:50 ` [PATCH v4 19/20] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 20/20] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201118145003.156542-19-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).