linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Coverity: elf_create_prefix_symbol(): Resource leaks
@ 2022-11-04 19:32 coverity-bot
  2022-11-08 21:10 ` Josh Poimboeuf
  0 siblings, 1 reply; 2+ messages in thread
From: coverity-bot @ 2022-11-04 19:32 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Thomas Gleixner, Peter Zijlstra, Miroslav Benes, linux-kernel,
	Mikulas Patocka, Josh Poimboeuf, Borislav Petkov, Yujie Liu,
	Gustavo A. R. Silva, linux-next, linux-hardening

Hello!

This is an experimental semi-automated report about issues detected by
Coverity from a scan of next-20221104 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by commits:

  Tue Nov 1 13:44:09 2022 +0100
    9f2899fe36a6 ("objtool: Add option to generate prefix symbols")

Coverity reported the following:

*** CID 1527141:  Resource leaks  (RESOURCE_LEAK)
tools/objtool/elf.c:833 in elf_create_prefix_symbol()
827     	struct symbol *sym = calloc(1, sizeof(*sym));
828     	size_t namelen = strlen(orig->name) + sizeof("__pfx_");
829     	char *name = malloc(namelen);
830
831     	if (!sym || !name) {
832     		perror("malloc");
vvv     CID 1527141:  Resource leaks  (RESOURCE_LEAK)
vvv     Variable "sym" going out of scope leaks the storage it points to.
833     		return NULL;
834     	}
835
836     	snprintf(name, namelen, "__pfx_%s", orig->name);
837
838     	sym->name = name;

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527141 ("Resource leaks")
Fixes: 9f2899fe36a6 ("objtool: Add option to generate prefix symbols")

Thanks for your attention!

-- 
Coverity-bot

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

* Re: Coverity: elf_create_prefix_symbol(): Resource leaks
  2022-11-04 19:32 Coverity: elf_create_prefix_symbol(): Resource leaks coverity-bot
@ 2022-11-08 21:10 ` Josh Poimboeuf
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Poimboeuf @ 2022-11-08 21:10 UTC (permalink / raw)
  To: coverity-bot
  Cc: Peter Zijlstra, Thomas Gleixner, Miroslav Benes, linux-kernel,
	Mikulas Patocka, Borislav Petkov, Yujie Liu, Gustavo A. R. Silva,
	linux-next, linux-hardening

On Fri, Nov 04, 2022 at 12:32:38PM -0700, coverity-bot wrote:
> Hello!
> 
> This is an experimental semi-automated report about issues detected by
> Coverity from a scan of next-20221104 as part of the linux-next scan project:
> https://scan.coverity.com/projects/linux-next-weekly-scan
> 
> You're getting this email because you were associated with the identified
> lines of code (noted below) that were touched by commits:
> 
>   Tue Nov 1 13:44:09 2022 +0100
>     9f2899fe36a6 ("objtool: Add option to generate prefix symbols")
> 
> Coverity reported the following:
> 
> *** CID 1527141:  Resource leaks  (RESOURCE_LEAK)
> tools/objtool/elf.c:833 in elf_create_prefix_symbol()
> 827     	struct symbol *sym = calloc(1, sizeof(*sym));
> 828     	size_t namelen = strlen(orig->name) + sizeof("__pfx_");
> 829     	char *name = malloc(namelen);
> 830
> 831     	if (!sym || !name) {
> 832     		perror("malloc");
> vvv     CID 1527141:  Resource leaks  (RESOURCE_LEAK)
> vvv     Variable "sym" going out of scope leaks the storage it points to.
> 833     		return NULL;
> 834     	}
> 835
> 836     	snprintf(name, namelen, "__pfx_%s", orig->name);
> 837
> 838     	sym->name = name;
> 
> If this is a false positive, please let us know so we can mark it as
> such, or teach the Coverity rules to be smarter. If not, please make
> sure fixes get into linux-next. :) For patches fixing this, please
> include these lines (but double-check the "Fixes" first):
> 
> Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
> Addresses-Coverity-ID: 1527141 ("Resource leaks")
> Fixes: 9f2899fe36a6 ("objtool: Add option to generate prefix symbols")

Please disable resource leak checking in objtool.  It's a short-lived
userspace tool for which we generally don't care about memory leaks.

-- 
Josh

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

end of thread, other threads:[~2022-11-08 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-04 19:32 Coverity: elf_create_prefix_symbol(): Resource leaks coverity-bot
2022-11-08 21:10 ` Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).