* [PATCH][next] fs/ntfs3: Fix a memory leak on object opts
@ 2021-09-10 10:02 Colin King
2021-09-10 10:50 ` Kari Argillander
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2021-09-10 10:02 UTC (permalink / raw)
To: Konstantin Komarov, ntfs3; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently a failed allocation on sbi->upcase will cause an exit via
the label free_sbi causing a memory leak on object opts. Fix this by
re-ordering the exit paths free_opts and free_sbi so that kfree's occur
in the reverse allocation order.
Addresses-Coverity: ("Resource leak")
Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
fs/ntfs3/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 3cba0b5e7ac7..69f23db0d727 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1450,10 +1450,10 @@ static int ntfs_init_fs_context(struct fs_context *fc)
fc->ops = &ntfs_context_ops;
return 0;
-free_opts:
- kfree(opts);
free_sbi:
kfree(sbi);
+free_opts:
+ kfree(opts);
return -ENOMEM;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] fs/ntfs3: Fix a memory leak on object opts
2021-09-10 10:02 [PATCH][next] fs/ntfs3: Fix a memory leak on object opts Colin King
@ 2021-09-10 10:50 ` Kari Argillander
2021-09-20 16:12 ` Konstantin Komarov
0 siblings, 1 reply; 3+ messages in thread
From: Kari Argillander @ 2021-09-10 10:50 UTC (permalink / raw)
To: Colin King; +Cc: Konstantin Komarov, ntfs3, kernel-janitors, linux-kernel
On Fri, Sep 10, 2021 at 11:02:02AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently a failed allocation on sbi->upcase will cause an exit via
> the label free_sbi causing a memory leak on object opts. Fix this by
> re-ordering the exit paths free_opts and free_sbi so that kfree's occur
> in the reverse allocation order.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
Thanks Colin.
Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
> fs/ntfs3/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 3cba0b5e7ac7..69f23db0d727 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -1450,10 +1450,10 @@ static int ntfs_init_fs_context(struct fs_context *fc)
> fc->ops = &ntfs_context_ops;
>
> return 0;
> -free_opts:
> - kfree(opts);
> free_sbi:
> kfree(sbi);
> +free_opts:
> + kfree(opts);
> return -ENOMEM;
> }
>
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] fs/ntfs3: Fix a memory leak on object opts
2021-09-10 10:50 ` Kari Argillander
@ 2021-09-20 16:12 ` Konstantin Komarov
0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Komarov @ 2021-09-20 16:12 UTC (permalink / raw)
To: Kari Argillander, Colin King; +Cc: ntfs3, kernel-janitors, linux-kernel
On 10.09.2021 13:50, Kari Argillander wrote:
> On Fri, Sep 10, 2021 at 11:02:02AM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently a failed allocation on sbi->upcase will cause an exit via
>> the label free_sbi causing a memory leak on object opts. Fix this by
>> re-ordering the exit paths free_opts and free_sbi so that kfree's occur
>> in the reverse allocation order.
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>
> Thanks Colin.
>
> Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
>
>> fs/ntfs3/super.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
>> index 3cba0b5e7ac7..69f23db0d727 100644
>> --- a/fs/ntfs3/super.c
>> +++ b/fs/ntfs3/super.c
>> @@ -1450,10 +1450,10 @@ static int ntfs_init_fs_context(struct fs_context *fc)
>> fc->ops = &ntfs_context_ops;
>>
>> return 0;
>> -free_opts:
>> - kfree(opts);
>> free_sbi:
>> kfree(sbi);
>> +free_opts:
>> + kfree(opts);
>> return -ENOMEM;
>> }
>>
>> --
>> 2.32.0
>>
Hi, Colin, Kari!
Thanks for work - applied!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-20 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 10:02 [PATCH][next] fs/ntfs3: Fix a memory leak on object opts Colin King
2021-09-10 10:50 ` Kari Argillander
2021-09-20 16:12 ` Konstantin Komarov
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).