linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ubifs: fix memory leak on error condition
@ 2018-11-15 20:38 Garry McNulty
  2018-11-15 21:42 ` Richard Weinberger
  0 siblings, 1 reply; 3+ messages in thread
From: Garry McNulty @ 2018-11-15 20:38 UTC (permalink / raw)
  To: linux-mtd
  Cc: richard, dedekind1, adrian.hunter, s.hauer, linux-kernel, Garry McNulty

If the call to ubifs_read_nnode() fails in ubifs_lpt_calc_hash() an
error is returned without freeing the memory allocated to 'buf'.
Jump to 'out' label to free allocated memory and return the error code.

Detected by CoverityScan, CID 1441025 ("Resource leak")

Signed-off-by: Garry McNulty <garrmcnu@gmail.com>
---
 fs/ubifs/lpt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index d1d5e96350dd..c162459a1e02 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1688,7 +1688,7 @@ int ubifs_lpt_calc_hash(struct ubifs_info *c, u8 *hash)
 	if (!c->nroot) {
 		err = ubifs_read_nnode(c, NULL, 0);
 		if (err)
-			return err;
+			goto out;
 	}
 
 	cnode = (struct ubifs_cnode *)c->nroot;
-- 
2.14.5


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

* Re: [PATCH] ubifs: fix memory leak on error condition
  2018-11-15 20:38 [PATCH] ubifs: fix memory leak on error condition Garry McNulty
@ 2018-11-15 21:42 ` Richard Weinberger
  2018-11-15 22:45   ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2018-11-15 21:42 UTC (permalink / raw)
  To: Garry McNulty
  Cc: linux-mtd, dedekind1, adrian.hunter, s.hauer, linux-kernel, colin.king

Am Donnerstag, 15. November 2018, 21:38:50 CET schrieb Garry McNulty:
> If the call to ubifs_read_nnode() fails in ubifs_lpt_calc_hash() an
> error is returned without freeing the memory allocated to 'buf'.
> Jump to 'out' label to free allocated memory and return the error code.
> 
> Detected by CoverityScan, CID 1441025 ("Resource leak")
> 
> Signed-off-by: Garry McNulty <garrmcnu@gmail.com>
> ---
>  fs/ubifs/lpt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
> index d1d5e96350dd..c162459a1e02 100644
> --- a/fs/ubifs/lpt.c
> +++ b/fs/ubifs/lpt.c
> @@ -1688,7 +1688,7 @@ int ubifs_lpt_calc_hash(struct ubifs_info *c, u8 *hash)
>  	if (!c->nroot) {
>  		err = ubifs_read_nnode(c, NULL, 0);
>  		if (err)
> -			return err;
> +			goto out;
>  	}
>  
>  	cnode = (struct ubifs_cnode *)c->nroot;

Please see:
http://lists.infradead.org/pipermail/linux-mtd/2018-October/085081.html

If Colin won't send a v2, please do you so, then I'll take your v2.

Thanks,
//richard



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

* Re: [PATCH] ubifs: fix memory leak on error condition
  2018-11-15 21:42 ` Richard Weinberger
@ 2018-11-15 22:45   ` Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2018-11-15 22:45 UTC (permalink / raw)
  To: Richard Weinberger, Garry McNulty
  Cc: linux-mtd, dedekind1, adrian.hunter, s.hauer, linux-kernel

On 15/11/2018 21:42, Richard Weinberger wrote:
> Am Donnerstag, 15. November 2018, 21:38:50 CET schrieb Garry McNulty:
>> If the call to ubifs_read_nnode() fails in ubifs_lpt_calc_hash() an
>> error is returned without freeing the memory allocated to 'buf'.
>> Jump to 'out' label to free allocated memory and return the error code.
>>
>> Detected by CoverityScan, CID 1441025 ("Resource leak")
>>
>> Signed-off-by: Garry McNulty <garrmcnu@gmail.com>
>> ---
>>  fs/ubifs/lpt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
>> index d1d5e96350dd..c162459a1e02 100644
>> --- a/fs/ubifs/lpt.c
>> +++ b/fs/ubifs/lpt.c
>> @@ -1688,7 +1688,7 @@ int ubifs_lpt_calc_hash(struct ubifs_info *c, u8 *hash)
>>  	if (!c->nroot) {
>>  		err = ubifs_read_nnode(c, NULL, 0);
>>  		if (err)
>> -			return err;
>> +			goto out;
>>  	}
>>  
>>  	cnode = (struct ubifs_cnode *)c->nroot;
> 
> Please see:
> http://lists.infradead.org/pipermail/linux-mtd/2018-October/085081.html
> 
> If Colin won't send a v2, please do you so, then I'll take your v2.

Please take Garry's V2, sorry, I somehow overlooked doing a V2.

> 
> Thanks,
> //richard
> 
> 


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

end of thread, other threads:[~2018-11-15 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15 20:38 [PATCH] ubifs: fix memory leak on error condition Garry McNulty
2018-11-15 21:42 ` Richard Weinberger
2018-11-15 22:45   ` Colin Ian King

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).