All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Abel Wu <abel.w@icloud.com>
Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, hewenliang4@huawei.com,
	wuyun.wu@huawei.com
Subject: Re: [PATCH] PM: hibernate: add sanity check on power_kobj
Date: Mon, 1 Feb 2021 11:52:43 +0100	[thread overview]
Message-ID: <20210201105243.GA23135@duo.ucw.cz> (raw)
In-Reply-To: <20210201075041.1201-1-abel.w@icloud.com>

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]

On Mon 2021-02-01 02:50:41, Abel Wu wrote:
> 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.

I don't believe this is good idea. If the dependency is ever broken,
this will make failure more subtle and harder to debug.

> 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

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2021-02-01 10:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01  7:50 [PATCH] PM: hibernate: add sanity check on power_kobj Abel Wu
2021-02-01 10:52 ` Pavel Machek [this message]
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=20210201105243.GA23135@duo.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=abel.w@icloud.com \
    --cc=hewenliang4@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.