Commit 97007500 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Greg Kroah-Hartman

intel_th: sth: Sanitize packet callback's return values

According to the stm class interface, the packet callback should return
an error if it is asked to generate packets that it doesn't support.
When it succeeds, it should return number of bytes consumed from its
payload. Currently, for FLAG packet it mistakenly returns 1.

This patch addresses these issues.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2bed074a
...@@ -94,10 +94,13 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master, ...@@ -94,10 +94,13 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master,
case STP_PACKET_TRIG: case STP_PACKET_TRIG:
if (flags & STP_PACKET_TIMESTAMPED) if (flags & STP_PACKET_TIMESTAMPED)
reg += 4; reg += 4;
iowrite8(*payload, sth->base + reg); writeb_relaxed(*payload, sth->base + reg);
break; break;
case STP_PACKET_MERR: case STP_PACKET_MERR:
if (size > 4)
size = 4;
sth_iowrite(&out->MERR, payload, size); sth_iowrite(&out->MERR, payload, size);
break; break;
...@@ -107,8 +110,8 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master, ...@@ -107,8 +110,8 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master,
else else
outp = (u64 __iomem *)&out->FLAG; outp = (u64 __iomem *)&out->FLAG;
size = 1; size = 0;
sth_iowrite(outp, payload, size); writeb_relaxed(0, outp);
break; break;
case STP_PACKET_USER: case STP_PACKET_USER:
...@@ -129,6 +132,8 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master, ...@@ -129,6 +132,8 @@ static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master,
sth_iowrite(outp, payload, size); sth_iowrite(outp, payload, size);
break; break;
default:
return -ENOTSUPP;
} }
return size; return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment