ipmi:ipmb: Don't call ipmi_unregister_smi() on a register failure

The data structure won't be set up to be unregistered, and it can result in
crashes if the register fails.

Signed-off-by: Corey Minyard <minyard@acm.org>
This commit is contained in:
Corey Minyard 2022-09-09 20:31:39 -05:00 коммит произвёл Corey Minyard
Родитель ba5829c654
Коммит 80d98a3300
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -424,10 +424,8 @@ static void ipmi_ipmb_request_events(void *send_info)
/* We don't fetch events here. */
}
static int ipmi_ipmb_remove(struct i2c_client *client)
static void ipmi_ipmb_cleanup(struct ipmi_ipmb_dev *iidev)
{
struct ipmi_ipmb_dev *iidev = i2c_get_clientdata(client);
if (iidev->slave) {
i2c_slave_unregister(iidev->slave);
if (iidev->slave != iidev->client)
@ -436,7 +434,13 @@ static int ipmi_ipmb_remove(struct i2c_client *client)
iidev->slave = NULL;
iidev->client = NULL;
ipmi_ipmb_stop_thread(iidev);
}
static int ipmi_ipmb_remove(struct i2c_client *client)
{
struct ipmi_ipmb_dev *iidev = i2c_get_clientdata(client);
ipmi_ipmb_cleanup(iidev);
ipmi_unregister_smi(iidev->intf);
return 0;
@ -544,7 +548,7 @@ static int ipmi_ipmb_probe(struct i2c_client *client)
out_err:
if (slave && slave != client)
i2c_unregister_device(slave);
ipmi_ipmb_remove(client);
ipmi_ipmb_cleanup(iidev);
return rv;
}