public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chenzhou Feng <chenzhoux.feng@intel.com>,
	Chen Yu <yu.c.chen@intel.com>,
	syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.com
Subject: [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode
Date: Thu, 24 Aug 2023 00:13:29 +0800	[thread overview]
Message-ID: <20230823161329.7348-1-yu.c.chen@intel.com> (raw)

commit 5904de0d735b ("PM: hibernate: Do not get block device exclusively
in test_resume mode") fixes a hibernation issue under test_resume mode.
That commit is supposed to open the block device in non-exclusive mode
when in test_resume. However the code did the opposite, which is against
its description.

Fix this by really disabling exclusive mode under test_resume.

Reported-by: syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/000000000000761f5f0603324129@google.com/
Fixes: 5904de0d735b ("PM: hibernate: Do not get block device exclusively in test_resume mode")
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index f6ebcd00c410..c12b34dd529c 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1518,7 +1518,7 @@ static void *swsusp_holder;
 
 int swsusp_check(bool snapshot_test)
 {
-	void *holder = snapshot_test ? &swsusp_holder : NULL;
+	void *holder = snapshot_test ? NULL : &swsusp_holder;
 	int error;
 
 	hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ,
@@ -1573,7 +1573,7 @@ void swsusp_close(bool snapshot_test)
 		return;
 	}
 
-	blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL);
+	blkdev_put(hib_resume_bdev, snapshot_test ? NULL : &swsusp_holder);
 }
 
 /**
-- 
2.25.1


             reply	other threads:[~2023-08-23  8:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23 16:13 Chen Yu [this message]
2023-08-23  9:18 ` [PATCH] PM: hibernate: Fix the exclusive get block device in test_resume mode Pengfei Xu
2023-08-23 12:44 ` Rafael J. Wysocki

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=20230823161329.7348-1-yu.c.chen@intel.com \
    --to=yu.c.chen@intel.com \
    --cc=chenzhoux.feng@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=syzbot+38d04642cea49f3a3d2e@syzkaller.appspotmail.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