linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix writing maj:min to /sys/power/resume (fixes hiberation with systemd)
@ 2023-07-11 11:48 Azat Khuzhin
  2023-07-11 12:08 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Azat Khuzhin @ 2023-07-11 11:48 UTC (permalink / raw)
  To: linux-pm, linux-kernel; +Cc: Azat Khuzhin, Christoph Hellwig

resume_store() first calls lookup_bdev() and after tries to handle
maj:min, but it does not reset the error before, hence if you will write
maj:min you will get ENOENT:

    # echo 259:2 >| /sys/power/resume
    bash: echo: write error: No such file or directory

This also should fix hiberation via systemd, since it uses this way.

Fixes: 1e8c813b083c4 ("PM: hibernate: don't use early_lookup_bdev in resume_store")
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
---
 kernel/power/hibernate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index f62e89d0d906..e1b4bfa938dd 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1179,6 +1179,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
 		unsigned maj, min, offset;
 		char *p, dummy;
 
+		error = 0;
 		if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 ||
 		    sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset,
 				&dummy) == 3) {
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix writing maj:min to /sys/power/resume (fixes hiberation with systemd)
  2023-07-11 11:48 [PATCH] Fix writing maj:min to /sys/power/resume (fixes hiberation with systemd) Azat Khuzhin
@ 2023-07-11 12:08 ` Christoph Hellwig
  2023-07-11 18:01   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2023-07-11 12:08 UTC (permalink / raw)
  To: Azat Khuzhin; +Cc: linux-pm, linux-kernel, Christoph Hellwig

On Tue, Jul 11, 2023 at 01:48:12PM +0200, Azat Khuzhin wrote:
> resume_store() first calls lookup_bdev() and after tries to handle
> maj:min, but it does not reset the error before, hence if you will write
> maj:min you will get ENOENT:
> 
>     # echo 259:2 >| /sys/power/resume
>     bash: echo: write error: No such file or directory
> 
> This also should fix hiberation via systemd, since it uses this way.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix writing maj:min to /sys/power/resume (fixes hiberation with systemd)
  2023-07-11 12:08 ` Christoph Hellwig
@ 2023-07-11 18:01   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-07-11 18:01 UTC (permalink / raw)
  To: Christoph Hellwig, Azat Khuzhin; +Cc: linux-pm, linux-kernel

On Tue, Jul 11, 2023 at 2:08 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Tue, Jul 11, 2023 at 01:48:12PM +0200, Azat Khuzhin wrote:
> > resume_store() first calls lookup_bdev() and after tries to handle
> > maj:min, but it does not reset the error before, hence if you will write
> > maj:min you will get ENOENT:
> >
> >     # echo 259:2 >| /sys/power/resume
> >     bash: echo: write error: No such file or directory
> >
> > This also should fix hiberation via systemd, since it uses this way.
>
> Looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Applied as 6.5-rc material, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-11 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11 11:48 [PATCH] Fix writing maj:min to /sys/power/resume (fixes hiberation with systemd) Azat Khuzhin
2023-07-11 12:08 ` Christoph Hellwig
2023-07-11 18:01   ` Rafael J. Wysocki

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).