Skip to content

Commit 6ffa897

Browse files
aduggan-synagregkh
authored andcommitted
Input: synaptics-rmi4 - do not consume more data than we have (F11, F12)
commit 5d40d95 upstream. Currently, rmi_f11_attention() and rmi_f12_attention() functions update the attn_data data pointer and size based on the size of the expected size of the attention data. However, if the actual valid data in the attn buffer is less then the expected value then the updated data pointer will point to memory beyond the end of the attn buffer. Using the calculated valid_bytes instead will prevent this from happening. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20191025002527.3189-3-aduggan@synaptics.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e5995d6 commit 6ffa897

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/input/rmi4/rmi_f11.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,8 @@ static irqreturn_t rmi_f11_attention(int irq, void *ctx)
12841284
valid_bytes = f11->sensor.attn_size;
12851285
memcpy(f11->sensor.data_pkt, drvdata->attn_data.data,
12861286
valid_bytes);
1287-
drvdata->attn_data.data += f11->sensor.attn_size;
1288-
drvdata->attn_data.size -= f11->sensor.attn_size;
1287+
drvdata->attn_data.data += valid_bytes;
1288+
drvdata->attn_data.size -= valid_bytes;
12891289
} else {
12901290
error = rmi_read_block(rmi_dev,
12911291
data_base_addr, f11->sensor.data_pkt,

‎drivers/input/rmi4/rmi_f12.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ static irqreturn_t rmi_f12_attention(int irq, void *ctx)
212212
valid_bytes = sensor->attn_size;
213213
memcpy(sensor->data_pkt, drvdata->attn_data.data,
214214
valid_bytes);
215-
drvdata->attn_data.data += sensor->attn_size;
216-
drvdata->attn_data.size -= sensor->attn_size;
215+
drvdata->attn_data.data += valid_bytes;
216+
drvdata->attn_data.size -= valid_bytes;
217217
} else {
218218
retval = rmi_read_block(rmi_dev, f12->data_addr,
219219
sensor->data_pkt, sensor->pkt_size);

0 commit comments

Comments
 (0)