[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210201105243.GA23135@duo.ucw.cz>
Date: Mon, 1 Feb 2021 11:52:43 +0100
From: Pavel Machek <pavel@....cz>
To: Abel Wu <abel.w@...oud.com>
Cc: rjw@...ysocki.net, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, hewenliang4@...wei.com,
wuyun.wu@...wei.com
Subject: Re: [PATCH] PM: hibernate: add sanity check on power_kobj
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@...oud.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
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists