forked from sonic-net/sonic-linux-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
eb4278c
commit 88518ab
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
patch/0001-fix-os-crash-caused-by-optoe-when-class-switch.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 846abadb7505c10e85a3450a7343d6a89b5ecd96 Mon Sep 17 00:00:00 2001 | ||
From: philo <philo@micasnetworks.com> | ||
Date: Fri, 12 Jul 2024 11:12:58 +0800 | ||
Subject: [PATCH] fix os crash caused by optoe when class switch | ||
|
||
--- | ||
drivers/misc/eeprom/optoe.c | 8 ++++++-- | ||
1 file changed, 6 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c | ||
index 9129312a1..63bb8c46a 100644 | ||
--- a/drivers/misc/eeprom/optoe.c | ||
+++ b/drivers/misc/eeprom/optoe.c | ||
@@ -941,8 +941,10 @@ static ssize_t set_dev_class(struct device *dev, | ||
} else { | ||
/* one-address (eg QSFP) and CMIS family */ | ||
/* if it exists, remove 0x51 i2c address */ | ||
- if (optoe->client[1]) | ||
+ if (optoe->client[1]) { | ||
i2c_unregister_device(optoe->client[1]); | ||
+ optoe->client[1] = NULL; | ||
+ } | ||
optoe->bin.size = ONE_ADDR_EEPROM_SIZE; | ||
optoe->num_addresses = 1; | ||
} | ||
@@ -1224,8 +1226,10 @@ static int optoe_probe(struct i2c_client *client, | ||
|
||
err_struct: | ||
if (num_addresses == 2) { | ||
- if (optoe->client[1]) | ||
+ if (optoe->client[1]) { | ||
i2c_unregister_device(optoe->client[1]); | ||
+ optoe->client[1] = NULL; | ||
+ } | ||
} | ||
|
||
kfree(optoe->writebuf); | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters