The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp
@ 2025-02-26 22:49 Colin Ian King
  2025-02-26 23:20 ` Steven Rostedt
  2025-02-27  9:57 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Colin Ian King @ 2025-02-26 22:49 UTC (permalink / raw)
  To: Steven Rostedt, Catalin Marinas; +Cc: kernel-janitors, linux-kernel

There is a resource leak on fp on an error return path in function
parse_symbols that causes a resource leak. Fix this by adding in
the missing fclose.

Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 scripts/sorttable.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index 7b4b3714b1af..e35abf28d037 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -665,8 +665,10 @@ static int parse_symbols(const char *fname)
 
 		addr = strtoull(addr_str, NULL, 16);
 		size = strtoull(size_str, NULL, 16);
-		if (add_field(addr, size) < 0)
+		if (add_field(addr, size) < 0) {
+			fclose(fp);
 			return -1;
+		}
 	}
 	fclose(fp);
 
-- 
2.47.2


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

* Re: [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp
  2025-02-26 22:49 [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp Colin Ian King
@ 2025-02-26 23:20 ` Steven Rostedt
  2025-02-27  9:57 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2025-02-26 23:20 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Catalin Marinas, kernel-janitors, linux-kernel

On Wed, 26 Feb 2025 22:49:34 +0000
Colin Ian King <colin.i.king@gmail.com> wrote:

> There is a resource leak on fp on an error return path in function
> parse_symbols that causes a resource leak. Fix this by adding in
> the missing fclose.

This patch has already been sent, and it's not really a leak, as when this
returns -1, it causes the program to exit and that will close all file descriptors.

I said I'll take the other patch as a clean up though.

  https://lore.kernel.org/all/20250225053724.74582-1-dheeraj.linuxdev@gmail.com/

-- Steve


> 
> Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  scripts/sorttable.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/sorttable.c b/scripts/sorttable.c
> index 7b4b3714b1af..e35abf28d037 100644
> --- a/scripts/sorttable.c
> +++ b/scripts/sorttable.c
> @@ -665,8 +665,10 @@ static int parse_symbols(const char *fname)
>  
>  		addr = strtoull(addr_str, NULL, 16);
>  		size = strtoull(size_str, NULL, 16);
> -		if (add_field(addr, size) < 0)
> +		if (add_field(addr, size) < 0) {
> +			fclose(fp);
>  			return -1;
> +		}
>  	}
>  	fclose(fp);
>  


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

* Re: [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp
  2025-02-26 22:49 [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp Colin Ian King
  2025-02-26 23:20 ` Steven Rostedt
@ 2025-02-27  9:57 ` Dan Carpenter
  2025-02-27  9:58   ` Colin King (gmail)
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-02-27  9:57 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Steven Rostedt, Catalin Marinas, kernel-janitors, linux-kernel

On Wed, Feb 26, 2025 at 10:49:34PM +0000, Colin Ian King wrote:
> There is a resource leak on fp on an error return path in function
> parse_symbols that causes a resource leak. Fix this by adding in
> the missing fclose.
> 
> Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

This is in scripts/ so it doesn't really matter.  We're going to exit
and release everything immediately either way.

regards,
dan carpenter


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

* Re: [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp
  2025-02-27  9:57 ` Dan Carpenter
@ 2025-02-27  9:58   ` Colin King (gmail)
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King (gmail) @ 2025-02-27  9:58 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steven Rostedt, Catalin Marinas, kernel-janitors, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 649 bytes --]

On 27/02/2025 09:57, Dan Carpenter wrote:
> On Wed, Feb 26, 2025 at 10:49:34PM +0000, Colin Ian King wrote:
>> There is a resource leak on fp on an error return path in function
>> parse_symbols that causes a resource leak. Fix this by adding in
>> the missing fclose.
>>
>> Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> 
> This is in scripts/ so it doesn't really matter.  We're going to exit
> and release everything immediately either way.

Ack. Won't fix these issues in scripts in future.

> 
> regards,
> dan carpenter
> 


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4901 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

end of thread, other threads:[~2025-02-27  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 22:49 [PATCH][next] scripts/sorttable: Fix resource leak on file pointer fp Colin Ian King
2025-02-26 23:20 ` Steven Rostedt
2025-02-27  9:57 ` Dan Carpenter
2025-02-27  9:58   ` Colin King (gmail)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox