Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Corey Minyard and committed by
Corey Minyard
80d98a33 ba5829c6

+8 -4
+8 -4
drivers/char/ipmi/ipmi_ipmb.c
··· 424 424 /* We don't fetch events here. */ 425 425 } 426 426 427 - static int ipmi_ipmb_remove(struct i2c_client *client) 427 + static void ipmi_ipmb_cleanup(struct ipmi_ipmb_dev *iidev) 428 428 { 429 - struct ipmi_ipmb_dev *iidev = i2c_get_clientdata(client); 430 - 431 429 if (iidev->slave) { 432 430 i2c_slave_unregister(iidev->slave); 433 431 if (iidev->slave != iidev->client) ··· 434 436 iidev->slave = NULL; 435 437 iidev->client = NULL; 436 438 ipmi_ipmb_stop_thread(iidev); 439 + } 437 440 441 + static int ipmi_ipmb_remove(struct i2c_client *client) 442 + { 443 + struct ipmi_ipmb_dev *iidev = i2c_get_clientdata(client); 444 + 445 + ipmi_ipmb_cleanup(iidev); 438 446 ipmi_unregister_smi(iidev->intf); 439 447 440 448 return 0; ··· 548 544 out_err: 549 545 if (slave && slave != client) 550 546 i2c_unregister_device(slave); 551 - ipmi_ipmb_remove(client); 547 + ipmi_ipmb_cleanup(iidev); 552 548 return rv; 553 549 } 554 550