|
| 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 | + |
0 commit comments