[PATCH] objtool: Fix NULL printf() '%s' argument

Josh Poimboeuf posted 1 patch 8 months, 4 weeks ago
tools/objtool/builtin-check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] objtool: Fix NULL printf() '%s' argument
Posted by Josh Poimboeuf 8 months, 4 weeks ago
It's probably not the best idea to pass a string pointer to printf()
right after confirming said pointer is NULL.  Fix the typo and use
argv[i] instead.

Fixes: c5995abe1547 ("objtool: Improve error handling")
Closes: https://lore.kernel.org/20250326103854.309e3c60@canb.auug.org.au
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/builtin-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 2bdff910430e..e364ab6345d3 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -238,7 +238,7 @@ static void save_argv(int argc, const char **argv)
 	for (int i = 0; i < argc; i++) {
 		orig_argv[i] = strdup(argv[i]);
 		if (!orig_argv[i]) {
-			WARN_GLIBC("strdup(%s)", orig_argv[i]);
+			WARN_GLIBC("strdup(%s)", argv[i]);
 			exit(1);
 		}
 	};
-- 
2.48.1
Re: [PATCH] objtool: Fix NULL printf() '%s' argument
Posted by Stephen Rothwell 8 months, 4 weeks ago
Hi Josh,

On Tue, 25 Mar 2025 18:30:37 -0700 Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> It's probably not the best idea to pass a string pointer to printf()
> right after confirming said pointer is NULL.  Fix the typo and use
> argv[i] instead.
> 
> Fixes: c5995abe1547 ("objtool: Improve error handling")
> Closes: https://lore.kernel.org/20250326103854.309e3c60@canb.auug.org.au
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  tools/objtool/builtin-check.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> index 2bdff910430e..e364ab6345d3 100644
> --- a/tools/objtool/builtin-check.c
> +++ b/tools/objtool/builtin-check.c
> @@ -238,7 +238,7 @@ static void save_argv(int argc, const char **argv)
>  	for (int i = 0; i < argc; i++) {
>  		orig_argv[i] = strdup(argv[i]);
>  		if (!orig_argv[i]) {
> -			WARN_GLIBC("strdup(%s)", orig_argv[i]);
> +			WARN_GLIBC("strdup(%s)", argv[i]);
>  			exit(1);
>  		}
>  	};
> -- 
> 2.48.1
> 

Thanks.  I have applied this to the merge of the tip tree (which
include the tip-fixes tree) in linux-next today.  It fixes the build
failure for me.  I will apply it to the merge of the tip-fixes tree
tomorrow unless it has already been applied by then.

-- 
Cheers,
Stephen Rothwell
Re: [PATCH] objtool: Fix NULL printf() '%s' argument
Posted by Ingo Molnar 8 months, 4 weeks ago
* Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> Hi Josh,
> 
> On Tue, 25 Mar 2025 18:30:37 -0700 Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > It's probably not the best idea to pass a string pointer to printf()
> > right after confirming said pointer is NULL.  Fix the typo and use
> > argv[i] instead.
> > 
> > Fixes: c5995abe1547 ("objtool: Improve error handling")
> > Closes: https://lore.kernel.org/20250326103854.309e3c60@canb.auug.org.au
> > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> > ---
> >  tools/objtool/builtin-check.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> > index 2bdff910430e..e364ab6345d3 100644
> > --- a/tools/objtool/builtin-check.c
> > +++ b/tools/objtool/builtin-check.c
> > @@ -238,7 +238,7 @@ static void save_argv(int argc, const char **argv)
> >  	for (int i = 0; i < argc; i++) {
> >  		orig_argv[i] = strdup(argv[i]);
> >  		if (!orig_argv[i]) {
> > -			WARN_GLIBC("strdup(%s)", orig_argv[i]);
> > +			WARN_GLIBC("strdup(%s)", argv[i]);
> >  			exit(1);
> >  		}
> >  	};
> > -- 
> > 2.48.1
> > 
> 
> Thanks.  I have applied this to the merge of the tip tree (which
> include the tip-fixes tree) in linux-next today.  It fixes the build
> failure for me.  I will apply it to the merge of the tip-fixes tree
> tomorrow unless it has already been applied by then.

Thanks, I've re-spun tip/urgent, so the next -next iteration ought to 
pick up the fix.

	Ingo
Re: [PATCH] objtool: Fix NULL printf() '%s' argument
Posted by Stephen Rothwell 8 months, 3 weeks ago
Hi Ingo,

On Wed, 26 Mar 2025 08:26:00 +0100 Ingo Molnar <mingo@kernel.org> wrote:
>
> Thanks, I've re-spun tip/urgent, so the next -next iteration ought to 
> pick up the fix.

Excellent.

-- 
Cheers,
Stephen Rothwell