All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM/sleep: fix return value of __setup handler
@ 2022-02-28 22:05 Randy Dunlap
  2022-03-01 17:56 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Randy Dunlap @ 2022-02-28 22:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Randy Dunlap, Igor Zhbanov, Srinivas Pandruvada,
	Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm

If an invalid option is given for "test_suspend=<option>", the entire
string is added to init's environment, so return 1 instead of 0 from
the __setup handler.

  Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5
    test_suspend=invalid"

and

 Run /sbin/init as init process
   with arguments:
     /sbin/init
   with environment:
     HOME=/
     TERM=linux
     BOOT_IMAGE=/boot/bzImage-517rc5
     test_suspend=invalid

Fixes: 2ce986892faf ("PM / sleep: Enhance test_suspend option with repeat capability")
Fixes: 27ddcc6596e5 ("PM / sleep: Add state field to pm_states[] entries")
Fixes: a9d7052363a6 ("PM: Separate suspend to RAM functionality from core")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: linux-pm@vger.kernel.org
---
Would someone like warning messages added in case of bad option strings?

 kernel/power/suspend_test.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-next-20220228.orig/kernel/power/suspend_test.c
+++ linux-next-20220228/kernel/power/suspend_test.c
@@ -157,22 +157,22 @@ static int __init setup_test_suspend(cha
 	value++;
 	suspend_type = strsep(&value, ",");
 	if (!suspend_type)
-		return 0;
+		return 1;
 
 	repeat = strsep(&value, ",");
 	if (repeat) {
 		if (kstrtou32(repeat, 0, &test_repeat_count_max))
-			return 0;
+			return 1;
 	}
 
 	for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
 		if (!strcmp(pm_labels[i], suspend_type)) {
 			test_state_label = pm_labels[i];
-			return 0;
+			return 1;
 		}
 
 	printk(warn_bad_state, suspend_type);
-	return 0;
+	return 1;
 }
 __setup("test_suspend", setup_test_suspend);
 

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

* Re: [PATCH] PM/sleep: fix return value of __setup handler
  2022-02-28 22:05 [PATCH] PM/sleep: fix return value of __setup handler Randy Dunlap
@ 2022-03-01 17:56 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-03-01 17:56 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linux Kernel Mailing List, Igor Zhbanov, Srinivas Pandruvada,
	Rafael J. Wysocki, Len Brown, Pavel Machek, Linux PM

On Mon, Feb 28, 2022 at 11:05 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> If an invalid option is given for "test_suspend=<option>", the entire
> string is added to init's environment, so return 1 instead of 0 from
> the __setup handler.
>
>   Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5
>     test_suspend=invalid"
>
> and
>
>  Run /sbin/init as init process
>    with arguments:
>      /sbin/init
>    with environment:
>      HOME=/
>      TERM=linux
>      BOOT_IMAGE=/boot/bzImage-517rc5
>      test_suspend=invalid
>
> Fixes: 2ce986892faf ("PM / sleep: Enhance test_suspend option with repeat capability")
> Fixes: 27ddcc6596e5 ("PM / sleep: Add state field to pm_states[] entries")
> Fixes: a9d7052363a6 ("PM: Separate suspend to RAM functionality from core")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
> Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: linux-pm@vger.kernel.org
> ---
> Would someone like warning messages added in case of bad option strings?
>
>  kernel/power/suspend_test.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- linux-next-20220228.orig/kernel/power/suspend_test.c
> +++ linux-next-20220228/kernel/power/suspend_test.c
> @@ -157,22 +157,22 @@ static int __init setup_test_suspend(cha
>         value++;
>         suspend_type = strsep(&value, ",");
>         if (!suspend_type)
> -               return 0;
> +               return 1;
>
>         repeat = strsep(&value, ",");
>         if (repeat) {
>                 if (kstrtou32(repeat, 0, &test_repeat_count_max))
> -                       return 0;
> +                       return 1;
>         }
>
>         for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
>                 if (!strcmp(pm_labels[i], suspend_type)) {
>                         test_state_label = pm_labels[i];
> -                       return 0;
> +                       return 1;
>                 }
>
>         printk(warn_bad_state, suspend_type);
> -       return 0;
> +       return 1;
>  }
>  __setup("test_suspend", setup_test_suspend);

Applied as 5.18 material, thanks!

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

end of thread, other threads:[~2022-03-01 17:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 22:05 [PATCH] PM/sleep: fix return value of __setup handler Randy Dunlap
2022-03-01 17:56 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.