Skip to content

Commit 88518ab

Browse files
Fix os crash caused by optoe when class switch (sonic-net#413)
Why: When the device is initially set to optoe2, there is an option ->client [1]. If echo 3>dev_class is manually set at this time, as for optoe3, option ->client [1] is meaningless but the content is still the address data of optoe2, accessing an illegal address will occur, causing the device to crash. How: Set option->client[1] to NULL when unregistering device Closes: sonic-net#412 Signed-off-by: philo <philo@micasnetworks.com> Co-authored-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent eb4278c commit 88518ab

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 846abadb7505c10e85a3450a7343d6a89b5ecd96 Mon Sep 17 00:00:00 2001
2+
From: philo <philo@micasnetworks.com>
3+
Date: Fri, 12 Jul 2024 11:12:58 +0800
4+
Subject: [PATCH] fix os crash caused by optoe when class switch
5+
6+
---
7+
drivers/misc/eeprom/optoe.c | 8 ++++++--
8+
1 file changed, 6 insertions(+), 2 deletions(-)
9+
10+
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c
11+
index 9129312a1..63bb8c46a 100644
12+
--- a/drivers/misc/eeprom/optoe.c
13+
+++ b/drivers/misc/eeprom/optoe.c
14+
@@ -941,8 +941,10 @@ static ssize_t set_dev_class(struct device *dev,
15+
} else {
16+
/* one-address (eg QSFP) and CMIS family */
17+
/* if it exists, remove 0x51 i2c address */
18+
- if (optoe->client[1])
19+
+ if (optoe->client[1]) {
20+
i2c_unregister_device(optoe->client[1]);
21+
+ optoe->client[1] = NULL;
22+
+ }
23+
optoe->bin.size = ONE_ADDR_EEPROM_SIZE;
24+
optoe->num_addresses = 1;
25+
}
26+
@@ -1224,8 +1226,10 @@ static int optoe_probe(struct i2c_client *client,
27+
28+
err_struct:
29+
if (num_addresses == 2) {
30+
- if (optoe->client[1])
31+
+ if (optoe->client[1]) {
32+
i2c_unregister_device(optoe->client[1]);
33+
+ optoe->client[1] = NULL;
34+
+ }
35+
}
36+
37+
kfree(optoe->writebuf);
38+
--
39+
2.25.1
40+

patch/series

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ cisco-npu-disable-other-bars.patch
214214
# Security patch
215215
0001-Change-the-system.map-file-permission-only-readable-.patch
216216

217+
# Micas patches
218+
0001-fix-os-crash-caused-by-optoe-when-class-switch.patch
219+
217220
#
218221
#
219222
############################################################

0 commit comments

Comments
 (0)