Skip to content

Commit 5d40d95

Browse files
aduggan-synadtor
authored andcommitted
Input: synaptics-rmi4 - do not consume more data than we have (F11, F12)
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 <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent f6aabe1 commit 5d40d95

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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)