lkml.org 
[lkml]   [2017]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 2/8] boot/param: add pointer to current and next argument to unknown parameter callback
Hello,

On Wed, 15 Nov 2017 20:47:14 +0530
Hari Bathini <hbathini@linux.vnet.ibm.com> wrote:

> From: Michal Suchanek <msuchanek@suse.de>
>
> Add pointer to current and next argument to make parameter processing
> more robust. This can make parameter processing easier and less error
> prone in cases where the parameters need to be enforced/ignored based
> on firmware/system state.
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>

> @@ -179,16 +183,18 @@ char *parse_args(const char *doing,
> if (*args)
> pr_debug("doing %s, parsing ARGS: '%s'\n", doing,
> args);
> - while (*args) {
> + next = next_arg(args, &param, &val);
> + while (*next) {
> int ret;
> int irq_was_disabled;
>
> - args = next_arg(args, &param, &val);
> + args = next;
> + next = next_arg(args, &param, &val);
> /* Stop at -- */

The [PATCH v8 5/6] you refreshed here moves the while(*next) to the end
of the cycle for a reason. Checking *args at the start is mostly
equivalent checking *next at the end. Checking *next at the start on
the other hand skips the last argument.

The "mostly" part is that there is a bug here because *args is not
checked at the start of the cycle making it possible to crash if it is
0. To fix that the if(*args) above should be extended to wrap the cycle.

Thanks

Michal

\
 
 \ /
  Last update: 2017-12-15 21:47    [W:0.110 / U:2.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site