diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-08-31 05:20:35 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-08-31 05:20:35 +0300 |
commit | a55b0a028877e9d7e7dacdbe363d39390554ba14 (patch) | |
tree | a332c0cd683c79a00fd2df7b9d80e25e71488b17 /drivers/char/ipmi | |
parent | ef2a0b7cdbc5b84f7b3f6573b7687e72bede0964 (diff) | |
parent | d40f09c1a23024f0e550d9423f4d389672e1dfaf (diff) | |
download | linux-a55b0a028877e9d7e7dacdbe363d39390554ba14.tar.xz |
Merge tag 'for-linus-6.6-1' of https://github.com/cminyard/linux-ipmi
Pull IPMI updates from Corey Minyard:
"Minor fixes for IPMI
Lots of small unconnected things, memory leaks on error, a possible
(though unlikely) deadlock, changes for updates to other things that
have changed. Nothing earth-shattering, but things that need update"
* tag 'for-linus-6.6-1' of https://github.com/cminyard/linux-ipmi:
ipmi_si: fix -Wvoid-pointer-to-enum-cast warning
ipmi: fix potential deadlock on &kcs_bmc->lock
ipmi_si: fix a memleak in try_smi_init()
ipmi: Change request_module to request_module_nowait
ipmi: make ipmi_class a static const structure
ipmi:ssif: Fix a memory leak when scanning for an adapter
ipmi:ssif: Add check for kstrdup
dt-bindings: ipmi: aspeed,ast2400-kcs-bmc: drop unneeded quotes
ipmi: Switch i2c drivers back to use .probe()
ipmi_watchdog: Fix read syscall not responding to signals during sleep
Diffstat (limited to 'drivers/char/ipmi')
-rw-r--r-- | drivers/char/ipmi/ipmb_dev_int.c | 2 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_devintf.c | 24 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_ipmb.c | 2 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 5 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_platform.c | 4 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_ssif.c | 11 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 2 | ||||
-rw-r--r-- | drivers/char/ipmi/kcs_bmc.c | 5 | ||||
-rw-r--r-- | drivers/char/ipmi/ssif_bmc.c | 2 |
9 files changed, 34 insertions, 23 deletions
diff --git a/drivers/char/ipmi/ipmb_dev_int.c b/drivers/char/ipmi/ipmb_dev_int.c index a0e9e80d92ee..49100845fcb7 100644 --- a/drivers/char/ipmi/ipmb_dev_int.c +++ b/drivers/char/ipmi/ipmb_dev_int.c @@ -366,7 +366,7 @@ static struct i2c_driver ipmb_driver = { .name = "ipmb-dev", .acpi_match_table = ACPI_PTR(acpi_ipmb_id), }, - .probe_new = ipmb_probe, + .probe = ipmb_probe, .remove = ipmb_remove, .id_table = ipmb_id, }; diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index 73e5a9e28f85..332082e02ea5 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -807,7 +807,9 @@ struct ipmi_reg_list { static LIST_HEAD(reg_list); static DEFINE_MUTEX(reg_list_mutex); -static struct class *ipmi_class; +static const struct class ipmi_class = { + .name = "ipmi", +}; static void ipmi_new_smi(int if_num, struct device *device) { @@ -822,7 +824,7 @@ static void ipmi_new_smi(int if_num, struct device *device) entry->dev = dev; mutex_lock(®_list_mutex); - device_create(ipmi_class, device, dev, NULL, "ipmi%d", if_num); + device_create(&ipmi_class, device, dev, NULL, "ipmi%d", if_num); list_add(&entry->link, ®_list); mutex_unlock(®_list_mutex); } @@ -840,7 +842,7 @@ static void ipmi_smi_gone(int if_num) break; } } - device_destroy(ipmi_class, dev); + device_destroy(&ipmi_class, dev); mutex_unlock(®_list_mutex); } @@ -860,15 +862,13 @@ static int __init init_ipmi_devintf(void) pr_info("ipmi device interface\n"); - ipmi_class = class_create("ipmi"); - if (IS_ERR(ipmi_class)) { - pr_err("ipmi: can't register device class\n"); - return PTR_ERR(ipmi_class); - } + rv = class_register(&ipmi_class); + if (rv) + return rv; rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); if (rv < 0) { - class_destroy(ipmi_class); + class_unregister(&ipmi_class); pr_err("ipmi: can't get major %d\n", ipmi_major); return rv; } @@ -880,7 +880,7 @@ static int __init init_ipmi_devintf(void) rv = ipmi_smi_watcher_register(&smi_watcher); if (rv) { unregister_chrdev(ipmi_major, DEVICE_NAME); - class_destroy(ipmi_class); + class_unregister(&ipmi_class); pr_warn("ipmi: can't register smi watcher\n"); return rv; } @@ -895,11 +895,11 @@ static void __exit cleanup_ipmi(void) mutex_lock(®_list_mutex); list_for_each_entry_safe(entry, entry2, ®_list, link) { list_del(&entry->link); - device_destroy(ipmi_class, entry->dev); + device_destroy(&ipmi_class, entry->dev); kfree(entry); } mutex_unlock(®_list_mutex); - class_destroy(ipmi_class); + class_unregister(&ipmi_class); ipmi_smi_watcher_unregister(&smi_watcher); unregister_chrdev(ipmi_major, DEVICE_NAME); } diff --git a/drivers/char/ipmi/ipmi_ipmb.c b/drivers/char/ipmi/ipmi_ipmb.c index 3f1c9f1573e7..4e335832fc26 100644 --- a/drivers/char/ipmi/ipmi_ipmb.c +++ b/drivers/char/ipmi/ipmi_ipmb.c @@ -572,7 +572,7 @@ static struct i2c_driver ipmi_ipmb_driver = { .name = DEVICE_NAME, .of_match_table = of_ipmi_ipmb_match, }, - .probe_new = ipmi_ipmb_probe, + .probe = ipmi_ipmb_probe, .remove = ipmi_ipmb_remove, .id_table = ipmi_ipmb_id, }; diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index abddd7e43a9a..5cd031f3fc97 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2082,6 +2082,11 @@ static int try_smi_init(struct smi_info *new_smi) new_smi->io.io_cleanup = NULL; } + if (rv && new_smi->si_sm) { + kfree(new_smi->si_sm); + new_smi->si_sm = NULL; + } + return rv; } diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c index 505cc978c97a..c3d8ac7873ba 100644 --- a/drivers/char/ipmi/ipmi_si_platform.c +++ b/drivers/char/ipmi/ipmi_si_platform.c @@ -269,7 +269,7 @@ static int of_ipmi_probe(struct platform_device *pdev) } memset(&io, 0, sizeof(io)); - io.si_type = (enum si_type) match->data; + io.si_type = (unsigned long) match->data; io.addr_source = SI_DEVICETREE; io.irq_setup = ipmi_std_irq_setup; @@ -381,7 +381,7 @@ static int acpi_ipmi_probe(struct platform_device *pdev) dev_info(dev, "%pR regsize %d spacing %d irq %d\n", res, io.regsize, io.regspacing, io.irq); - request_module("acpi_ipmi"); + request_module_nowait("acpi_ipmi"); return ipmi_si_add_smi(&io); } diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 3b921c78ba08..df8dd50b4cbe 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -1400,7 +1400,7 @@ static struct ssif_addr_info *ssif_info_find(unsigned short addr, restart: list_for_each_entry(info, &ssif_infos, link) { if (info->binfo.addr == addr) { - if (info->addr_src == SI_SMBIOS) + if (info->addr_src == SI_SMBIOS && !info->adapter_name) info->adapter_name = kstrdup(adapter_name, GFP_KERNEL); @@ -1439,7 +1439,7 @@ static bool check_acpi(struct ssif_info *ssif_info, struct device *dev) if (acpi_handle) { ssif_info->addr_source = SI_ACPI; ssif_info->addr_info.acpi_info.acpi_handle = acpi_handle; - request_module("acpi_ipmi"); + request_module_nowait("acpi_ipmi"); return true; } #endif @@ -1600,6 +1600,11 @@ static int ssif_add_infos(struct i2c_client *client) info->addr_src = SI_ACPI; info->client = client; info->adapter_name = kstrdup(client->adapter->name, GFP_KERNEL); + if (!info->adapter_name) { + kfree(info); + return -ENOMEM; + } + info->binfo.addr = client->addr; list_add_tail(&info->link, &ssif_infos); return 0; @@ -2054,7 +2059,7 @@ static struct i2c_driver ssif_i2c_driver = { .driver = { .name = DEVICE_NAME }, - .probe_new = ssif_probe, + .probe = ssif_probe, .remove = ssif_remove, .alert = ssif_alert, .id_table = ssif_id, diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 0d4a8dcacfd4..9a459257489f 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -802,7 +802,7 @@ static ssize_t ipmi_read(struct file *file, init_waitqueue_entry(&wait, current); add_wait_queue(&read_q, &wait); - while (!data_to_read) { + while (!data_to_read && !signal_pending(current)) { set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irq(&ipmi_read_lock); schedule(); diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c index 03d02a848f3a..8b1161d5194a 100644 --- a/drivers/char/ipmi/kcs_bmc.c +++ b/drivers/char/ipmi/kcs_bmc.c @@ -56,12 +56,13 @@ irqreturn_t kcs_bmc_handle_event(struct kcs_bmc_device *kcs_bmc) { struct kcs_bmc_client *client; irqreturn_t rc = IRQ_NONE; + unsigned long flags; - spin_lock(&kcs_bmc->lock); + spin_lock_irqsave(&kcs_bmc->lock, flags); client = kcs_bmc->client; if (client) rc = client->ops->event(client); - spin_unlock(&kcs_bmc->lock); + spin_unlock_irqrestore(&kcs_bmc->lock, flags); return rc; } diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c index caee848261e9..56346fb32872 100644 --- a/drivers/char/ipmi/ssif_bmc.c +++ b/drivers/char/ipmi/ssif_bmc.c @@ -860,7 +860,7 @@ static struct i2c_driver ssif_bmc_driver = { .name = DEVICE_NAME, .of_match_table = ssif_bmc_match, }, - .probe_new = ssif_bmc_probe, + .probe = ssif_bmc_probe, .remove = ssif_bmc_remove, .id_table = ssif_bmc_id, }; |