From: Abel Wu <abel.w@icloud.com>
To: rjw@rjwysocki.net, pavel@ucw.cz
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
hewenliang4@huawei.com, wuyun.wu@huawei.com,
Abel Wu <abel.w@icloud.com>
Subject: [PATCH] PM: hibernate: add sanity check on power_kobj
Date: Mon, 1 Feb 2021 02:50:41 -0500 [thread overview]
Message-ID: <20210201075041.1201-1-abel.w@icloud.com> (raw)
The @power_kobj is initialized in pm_init() which is the same
initcall level as pm_disk_init(). Although this dependency is
guaranteed based on the current initcall serial execution model,
it would still be better do a cost-less sanity check to avoid
oops once the dependency is broken.
Signed-off-by: Abel Wu <abel.w@icloud.com>
---
kernel/power/hibernate.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index da0b41914177..060089cc261d 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1262,6 +1262,9 @@ static const struct attribute_group attr_group = {
static int __init pm_disk_init(void)
{
+ if (!power_kobj)
+ return -EINVAL;
+
return sysfs_create_group(power_kobj, &attr_group);
}
--
2.27.0
next reply other threads:[~2021-02-01 8:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 7:50 Abel Wu [this message]
2021-02-01 10:52 ` [PATCH] PM: hibernate: add sanity check on power_kobj Pavel Machek
2021-02-02 1:59 ` Abel Wu
2021-02-02 9:04 ` Pavel Machek
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=20210201075041.1201-1-abel.w@icloud.com \
--to=abel.w@icloud.com \
--cc=hewenliang4@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=wuyun.wu@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).