All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot]  [PATCH] fs: fat: Fix possible double free of fatbuf
@ 2019-05-16 14:34 Andrew F. Davis
  2019-05-29 17:16 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew F. Davis @ 2019-05-16 14:34 UTC (permalink / raw)
  To: u-boot

fat_itr_root() allocates fatbuf so we free it on the exit path, if
the function fails we should not free it, check the return value
and skip freeing if the function fails.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 fs/fat/fat.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index c5997c2173..06c8ed14bd 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1134,11 +1134,12 @@ int fat_size(const char *filename, loff_t *size)
 		 * expected to fail if passed a directory path:
 		 */
 		free(fsdata.fatbuf);
-		fat_itr_root(itr, &fsdata);
-		if (!fat_itr_resolve(itr, filename, TYPE_DIR)) {
+		ret = fat_itr_root(itr, &fsdata);
+		if (ret)
+			goto out_free_itr;
+		ret = fat_itr_resolve(itr, filename, TYPE_DIR);
+		if (!ret)
 			*size = 0;
-			ret = 0;
-		}
 		goto out_free_both;
 	}
 
-- 
2.17.1

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

* [U-Boot] [PATCH] fs: fat: Fix possible double free of fatbuf
  2019-05-16 14:34 [U-Boot] [PATCH] fs: fat: Fix possible double free of fatbuf Andrew F. Davis
@ 2019-05-29 17:16 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2019-05-29 17:16 UTC (permalink / raw)
  To: u-boot

On Thu, May 16, 2019 at 09:34:31AM -0500, Andrew F. Davis wrote:

> fat_itr_root() allocates fatbuf so we free it on the exit path, if
> the function fails we should not free it, check the return value
> and skip freeing if the function fails.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190529/a69554b3/attachment.sig>

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

end of thread, other threads:[~2019-05-29 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 14:34 [U-Boot] [PATCH] fs: fat: Fix possible double free of fatbuf Andrew F. Davis
2019-05-29 17:16 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.