Commit ae5b69c
eeprom: fram: Fix read/write length and buffer pointer arithmetic
Fixes two critical bugs in the Fujitsu MB85RCxx I2C FRAM driver when
handling transfers that cross page boundaries:
Fixes incorrect write length: The mb85rcxx_write function was
incorrectly passing the total remaining length (len) to the
underlying I2C transfer instead of the page-limited length (len_in_page).
This resulted in I2C errors or data corruption when writing past a page
boundary.
Fixes buffer pointer update: Corrects the loop's buffer pointer
arithmetic in both mb85rcxx_read and mb85rcxx_write. The original
code used incorrect casting (*(char *)&buf += len_in_page;), leading
to a strict aliasing violation and potentially undefined behavior.
The pointer is now correctly advanced using explicit casting:
- mb85rcxx_read: buf = (char *)buf + len_in_page;
- mb85rcxx_write: buf = (const char *)buf + len_in_page;
Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>1 parent bfdfe99 commit ae5b69c
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
0 commit comments