提交 4bbaf258 编写于 作者: H Hendrik Brueckner 提交者: Martin Schwidefsky

s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero

Correct a trinity finding for the perf_event_open() system call with
a perf event attribute structure that uses a frequency but has the
sampling frequency set to zero.  This causes a FP divide exception during
the sample rate initialization for the hardware sampling facility.

Fixes: 8c069ff4 ("s390/perf: add support for the CPU-Measurement Sampling Facility")
Cc: stable@vger.kernel.org # 3.14+
Reviewed-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NHendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 de5cb6eb
...@@ -753,6 +753,10 @@ static int __hw_perf_event_init(struct perf_event *event) ...@@ -753,6 +753,10 @@ static int __hw_perf_event_init(struct perf_event *event)
*/ */
rate = 0; rate = 0;
if (attr->freq) { if (attr->freq) {
if (!attr->sample_freq) {
err = -EINVAL;
goto out;
}
rate = freq_to_sample_rate(&si, attr->sample_freq); rate = freq_to_sample_rate(&si, attr->sample_freq);
rate = hw_limit_rate(&si, rate); rate = hw_limit_rate(&si, rate);
attr->freq = 0; attr->freq = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册