diff mbox series

[-next] PM:hibernate:fix miss close 'hib_resume_bdev' in load_image_and_restore

Message ID 20220209112951.3073370-1-yebin10@huawei.com (mailing list archive)
State Mainlined, archived
Headers show
Series [-next] PM:hibernate:fix miss close 'hib_resume_bdev' in load_image_and_restore | expand

Commit Message

yebin (H) Feb. 9, 2022, 11:29 a.m. UTC
As 'swsusp_check' open 'hib_resume_bdev', if call 'create_basic_memory_bitmaps'
failed, we need to close 'hib_resume_bdev' in 'load_image_and_restore' function.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 kernel/power/hibernate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Rafael J. Wysocki Feb. 16, 2022, 6:48 p.m. UTC | #1
On Wed, Feb 9, 2022 at 12:13 PM Ye Bin <yebin10@huawei.com> wrote:
>
> As 'swsusp_check' open 'hib_resume_bdev', if call 'create_basic_memory_bitmaps'
> failed, we need to close 'hib_resume_bdev' in 'load_image_and_restore' function.
>
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
>  kernel/power/hibernate.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index e6af502c2fd7..49d1df0218cb 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -689,8 +689,10 @@ static int load_image_and_restore(void)
>
>         lock_device_hotplug();
>         error = create_basic_memory_bitmaps();
> -       if (error)
> +       if (error) {
> +               swsusp_close(FMODE_READ | FMODE_EXCL);
>                 goto Unlock;
> +       }
>
>         error = swsusp_read(&flags);
>         swsusp_close(FMODE_READ | FMODE_EXCL);
> --

Applied as 5.18 material, thanks!
diff mbox series

Patch

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index e6af502c2fd7..49d1df0218cb 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -689,8 +689,10 @@  static int load_image_and_restore(void)
 
 	lock_device_hotplug();
 	error = create_basic_memory_bitmaps();
-	if (error)
+	if (error) {
+		swsusp_close(FMODE_READ | FMODE_EXCL);
 		goto Unlock;
+	}
 
 	error = swsusp_read(&flags);
 	swsusp_close(FMODE_READ | FMODE_EXCL);