From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
To: openipmi-developer@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, minyard@acm.org,
ioanna-maria.alifieraki@canonical.com, minyard@mvista.com,
stable@vger.kernel.org
Subject: [PATCH 2/2] ipmi: fix initialization when workqueue allocation fails
Date: Fri, 17 Dec 2021 12:44:10 -0300 [thread overview]
Message-ID: <20211217154410.1228673-2-cascardo@canonical.com> (raw)
In-Reply-To: <20211217154410.1228673-1-cascardo@canonical.com>
If the workqueue allocation fails, the driver is marked as not initialized,
and timer and panic_notifier will be left registered.
Instead of removing those when workqueue allocation fails, do the workqueue
initialization before doing it, and cleanup srcu_struct if it fails.
Fixes: 1d49eb91e86e ("ipmi: Move remove_work to dedicated workqueue")
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Cc: Corey Minyard <cminyard@mvista.com>
Cc: Ioanna Alifieraki <ioanna-maria.alifieraki@canonical.com>
Cc: stable@vger.kernel.org
---
drivers/char/ipmi/ipmi_msghandler.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 84975b21fff2..266c7bc58dda 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -5396,20 +5396,23 @@ static int ipmi_init_msghandler(void)
if (rv)
goto out;
- timer_setup(&ipmi_timer, ipmi_timeout, 0);
- mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
-
- atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
-
remove_work_wq = create_singlethread_workqueue("ipmi-msghandler-remove-wq");
if (!remove_work_wq) {
pr_err("unable to create ipmi-msghandler-remove-wq workqueue");
rv = -ENOMEM;
- goto out;
+ goto out_wq;
}
+ timer_setup(&ipmi_timer, ipmi_timeout, 0);
+ mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
+
+ atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
+
initialized = true;
+out_wq:
+ if (rv)
+ cleanup_srcu_struct(&ipmi_interfaces_srcu);
out:
mutex_unlock(&ipmi_interfaces_mutex);
return rv;
--
2.32.0
next prev parent reply other threads:[~2021-12-17 15:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-17 15:44 [PATCH 1/2] ipmi: bail out if init_srcu_struct fails Thadeu Lima de Souza Cascardo
2021-12-17 15:44 ` Thadeu Lima de Souza Cascardo [this message]
2021-12-17 20:42 ` [PATCH 2/2] ipmi: fix initialization when workqueue allocation fails Corey Minyard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211217154410.1228673-2-cascardo@canonical.com \
--to=cascardo@canonical.com \
--cc=ioanna-maria.alifieraki@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=minyard@mvista.com \
--cc=openipmi-developer@lists.sourceforge.net \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®