From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Subject: [PATCH 2/8] powerpc/perf/hv-24x7: Fix off-by-one error in request_buffer check
Date: Thu, 1 Jun 2017 18:02:21 -0300 [thread overview]
Message-ID: <1496350947-30951-3-git-send-email-bauerman@linux.vnet.ibm.com> (raw)
In-Reply-To: <1496350947-30951-1-git-send-email-bauerman@linux.vnet.ibm.com>
request_buffer can hold 254 requests, so if it already has that number of
entries we can't add a new one.
Also, define constant to show where the number comes from.
Fixes: e3ee15dc5d19 ("powerpc/perf/hv-24x7: Define add_event_to_24x7_request()")
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
---
Notes:
This patch was already posted before:
https://patchwork.ozlabs.org/patch/735948/
arch/powerpc/perf/hv-24x7.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 1354cde7095c..141de0f708f7 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -166,6 +166,10 @@ DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw);
DEFINE_PER_CPU(char, hv_24x7_reqb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
DEFINE_PER_CPU(char, hv_24x7_resb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
+#define MAX_NUM_REQUESTS ((H24x7_DATA_BUFFER_SIZE - \
+ sizeof(struct hv_24x7_request_buffer)) \
+ / sizeof(struct hv_24x7_request))
+
static char *event_name(struct hv_24x7_event_data *ev, int *len)
{
*len = be16_to_cpu(ev->event_name_len) - 2;
@@ -1107,7 +1111,7 @@ static int add_event_to_24x7_request(struct perf_event *event,
int i;
struct hv_24x7_request *req;
- if (request_buffer->num_requests > 254) {
+ if (request_buffer->num_requests >= MAX_NUM_REQUESTS) {
pr_devel("Too many requests for 24x7 HCALL %d\n",
request_buffer->num_requests);
return -EINVAL;
--
2.7.4
next prev parent reply other threads:[~2017-06-01 21:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 21:02 [PATCH 0/8] Support for 24x7 hcall interface version 2 Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 1/8] powerpc/perf/hv-24x7: Fix passing of catalog version number Thiago Jung Bauermann
2017-06-01 21:02 ` Thiago Jung Bauermann [this message]
2017-06-01 21:02 ` [PATCH 3/8] powerpc/perf/hv-24x7: Properly iterate through results Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 4/8] powerpc-perf/hx-24x7: Don't log failed hcall twice Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 5/8] powerpc/perf/hv-24x7: Fix return value of hcalls Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 6/8] powerpc/perf/hv-24x7: Minor improvements Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 7/8] powerpc/perf/hv-24x7: Support v2 of the hypervisor API Thiago Jung Bauermann
2017-06-14 0:13 ` Sukadev Bhattiprolu
2017-06-14 22:25 ` Thiago Jung Bauermann
2017-06-01 21:02 ` [PATCH 8/8] powerpc/perf/hv-24x7: Aggregate result elements on POWER9 SMT8 Thiago Jung Bauermann
2017-06-14 4:33 ` [PATCH 0/8] Support for 24x7 hcall interface version 2 Sukadev Bhattiprolu
2017-06-27 12:44 ` Michael Ellerman
2017-06-28 22:02 ` Thiago Jung Bauermann
2017-06-29 5:14 ` Michael Ellerman
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=1496350947-30951-3-git-send-email-bauerman@linux.vnet.ibm.com \
--to=bauerman@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sukadev@linux.vnet.ibm.com \
/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).