Skip to content

Commit a910776

Browse files
authored
import upstream optoe chunk offset fix (#60)
Correct a panic inducing defect which is triggered on a read (or write) which begins beyond byte 128, on a byte which is not aligned on a 128 byte chunk boundary, and which crosses a chunk boundary. Signed-off-by: Guohan Lu <[email protected]>
1 parent 5b4c0aa commit a910776

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From e317fa8a47a3718d21edc9b66a7126b021b8ee6e Mon Sep 17 00:00:00 2001
2+
3+
From: Don Bollinger <[email protected]>
4+
5+
Subject: [PATCH] Correct a panic inducing defect which is triggered on a read
6+
(or write) which begins beyond byte 128, on a byte which is not aligned on a
7+
128 byte chunk boundary, and which crosses a chunk boundary.
8+
---
9+
drivers/misc/eeprom/optoe.c | 27 ++++++++++++++-------------
10+
1 file changed, 14 insertions(+), 13 deletions(-)
11+
12+
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c
13+
index 7425bf6..1b64506 100644
14+
--- a/drivers/misc/eeprom/optoe.c
15+
+++ b/drivers/misc/eeprom/optoe.c
16+
@@ -641,6 +641,7 @@ static ssize_t optoe_read_write(struct optoe_data *optoe,
17+
ssize_t retval;
18+
size_t pending_len = 0, chunk_len = 0;
19+
loff_t chunk_offset = 0, chunk_start_offset = 0;
20+
+ loff_t chunk_end_offset = 0;
21+
22+
dev_dbg(&client->dev,
23+
"%s: off %lld len:%ld, opcode:%s\n",
24+
@@ -678,30 +679,30 @@ static ssize_t optoe_read_write(struct optoe_data *optoe,
25+
/*
26+
* Compute the offset and number of bytes to be read/write
27+
*
28+
- * 1. start at offset 0 (within the chunk), and read/write
29+
- * the entire chunk
30+
- * 2. start at offset 0 (within the chunk) and read/write less
31+
- * than entire chunk
32+
- * 3. start at an offset not equal to 0 and read/write the rest
33+
+ * 1. start at an offset not equal to 0 (within the chunk)
34+
+ * and read/write less than the rest of the chunk
35+
+ * 2. start at an offset not equal to 0 and read/write the rest
36+
* of the chunk
37+
- * 4. start at an offset not equal to 0 and read/write less than
38+
- * (end of chunk - offset)
39+
+ * 3. start at offset 0 (within the chunk) and read/write less
40+
+ * than entire chunk
41+
+ * 4. start at offset 0 (within the chunk), and read/write
42+
+ * the entire chunk
43+
*/
44+
chunk_start_offset = chunk * OPTOE_PAGE_SIZE;
45+
+ chunk_end_offset = chunk_start_offset + OPTOE_PAGE_SIZE;
46+
47+
if (chunk_start_offset < off) {
48+
chunk_offset = off;
49+
- if ((off + pending_len) < (chunk_start_offset +
50+
- OPTOE_PAGE_SIZE))
51+
+ if ((off + pending_len) < chunk_end_offset)
52+
chunk_len = pending_len;
53+
else
54+
- chunk_len = OPTOE_PAGE_SIZE - off;
55+
+ chunk_len = chunk_end_offset - off;
56+
} else {
57+
chunk_offset = chunk_start_offset;
58+
- if (pending_len > OPTOE_PAGE_SIZE)
59+
- chunk_len = OPTOE_PAGE_SIZE;
60+
- else
61+
+ if (pending_len < OPTOE_PAGE_SIZE)
62+
chunk_len = pending_len;
63+
+ else
64+
+ chunk_len = OPTOE_PAGE_SIZE;
65+
}
66+
67+
dev_dbg(&client->dev,

patch/series

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ driver-hwmon-pmbus-dps1900.patch
3232
driver-support-tun-config-carrier-enable.patch
3333
driver-support-optoe.patch
3434
driver-support-optoe-EOF_fix.patch
35+
driver-support-optoe-chunk-offset-fix.patch
3536
bridge-add-per-port-broadcast-flood-flag.patch
3637
config-dell-s6000.patch
3738
config-dell-z9100.patch

0 commit comments

Comments
 (0)