diff mbox series

[11/30] swsusp: don't pass a stack address to blkdev_get_by_path

Message ID 20230608110258.189493-12-hch@lst.de (mailing list archive)
State Not Applicable
Headers show
Series [01/30] block: also call ->open for incremental partition opens | expand

Commit Message

Christoph Hellwig June 8, 2023, 11:02 a.m. UTC
holder is just an on-stack pointer that can easily be reused by other calls,
replace it with a static variable that doesn't change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 kernel/power/swap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki June 9, 2023, 6:13 p.m. UTC | #1
On Thu, Jun 8, 2023 at 1:03 PM Christoph Hellwig <hch@lst.de> wrote:
>
> holder is just an on-stack pointer that can easily be reused by other calls,
> replace it with a static variable that doesn't change.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Hannes Reinecke <hare@suse.de>

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  kernel/power/swap.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index 81aec3b2c60510..b03ff1a33c7f68 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -1510,6 +1510,8 @@ int swsusp_read(unsigned int *flags_p)
>         return error;
>  }
>
> +static void *swsusp_holder;
> +
>  /**
>   *      swsusp_check - Check for swsusp signature in the resume device
>   */
> @@ -1517,14 +1519,13 @@ int swsusp_read(unsigned int *flags_p)
>  int swsusp_check(bool snapshot_test)
>  {
>         int error;
> -       void *holder;
>         fmode_t mode = FMODE_READ;
>
>         if (snapshot_test)
>                 mode |= FMODE_EXCL;
>
>         hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device,
> -                                           mode, &holder, NULL);
> +                                           mode, &swsusp_holder, NULL);
>         if (!IS_ERR(hib_resume_bdev)) {
>                 set_blocksize(hib_resume_bdev, PAGE_SIZE);
>                 clear_page(swsusp_header);
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 81aec3b2c60510..b03ff1a33c7f68 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1510,6 +1510,8 @@  int swsusp_read(unsigned int *flags_p)
 	return error;
 }
 
+static void *swsusp_holder;
+
 /**
  *      swsusp_check - Check for swsusp signature in the resume device
  */
@@ -1517,14 +1519,13 @@  int swsusp_read(unsigned int *flags_p)
 int swsusp_check(bool snapshot_test)
 {
 	int error;
-	void *holder;
 	fmode_t mode = FMODE_READ;
 
 	if (snapshot_test)
 		mode |= FMODE_EXCL;
 
 	hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device,
-					    mode, &holder, NULL);
+					    mode, &swsusp_holder, NULL);
 	if (!IS_ERR(hib_resume_bdev)) {
 		set_blocksize(hib_resume_bdev, PAGE_SIZE);
 		clear_page(swsusp_header);