From ff0c049f1f6d170f2b75e9138d999cca33db9b20 Mon Sep 17 00:00:00 2001 From: philo Date: Tue, 2 Jul 2024 11:29:32 +0800 Subject: [PATCH] Fix os crash caused by optoe when class switch 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. Therefore, set option->client[1] to NULL when unregistering device Signed-off-by: philo --- ...sh-caused-by-optoe-when-class-switch.patch | 36 +++++++++++++++++++ patch/series | 3 ++ 2 files changed, 39 insertions(+) create mode 100644 patch/0001-fix-os-crash-caused-by-optoe-when-class-switch.patch diff --git a/patch/0001-fix-os-crash-caused-by-optoe-when-class-switch.patch b/patch/0001-fix-os-crash-caused-by-optoe-when-class-switch.patch new file mode 100644 index 000000000..f58a01583 --- /dev/null +++ b/patch/0001-fix-os-crash-caused-by-optoe-when-class-switch.patch @@ -0,0 +1,36 @@ +From b8ba60c6d604fee3f61e3d1e709e86c785b075f4 Mon Sep 17 00:00:00 2001 +From: philo +Date: Mon, 1 Jul 2024 11:03:35 +0800 +Subject: [PATCH] fix os crash caused by optoe when class switch + +--- + drivers/misc/eeprom/optoe.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c +index 9129312a1..a6bdbb9d1 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; + } +@@ -1226,6 +1228,7 @@ static int optoe_probe(struct i2c_client *client, + if (num_addresses == 2) { + if (optoe->client[1]) + i2c_unregister_device(optoe->client[1]); ++ optoe->client[1] = NULL; + } + + kfree(optoe->writebuf); +-- +2.25.1 + diff --git a/patch/series b/patch/series index 443b5d316..4c1f48300 100755 --- a/patch/series +++ b/patch/series @@ -214,6 +214,9 @@ cisco-npu-disable-other-bars.patch # Security patch 0001-Change-the-system.map-file-permission-only-readable-.patch +# Micas patches +0001-fix-os-crash-caused-by-optoe-when-class-switch.patch + # # ############################################################