fs: fat: memory leak in fat_unlink()
PATCH 1/1 fs: fat: memory leak in fat_unlink()
Do not leak filename_copy in case of error.
Catch out of memory when calling strdup.
This addresses Coverity Scan CID 184086.
Reported-by Tom Rini <[email protected]>
Signed-off-by Heinrich Schuchardt <[email protected]>
--- fs/fat/fat_write.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/fat/fat_write.c +7 -1
@@ -1263,6 +1263,11 @@ int fat_unlink(const char *filename)char *filename_copy, *dirname, *basename; filename_copy =strdup (filename); +if (!filename_copy) { +printf ("Error: allocating memory\n" ); + ret = -ENOMEM ; + goto exit; + }split_filename (filename_copy, &dirname, &basename);if (!strcmp (dirname,"/" ) && !strcmp (basename,"" )) {
@@ -1274,7 +1279,8 @@ int fat_unlink(const char *filename) itr =malloc_cache_aligned (sizeof (fat_itr));if (!itr) {printf ("Error: allocating memory\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto exit; } ret =fat_itr_root (itr, &fsdata);
Signature · 1 line
2.19.0
PATCH 1/1 fs: fat: memory leak in fat_unlink()
Quoted 4 lines · Heinrich Schuchardt
Do not leak
filename_copyin case of error.
Catch out of memory when calling strdup.This addresses Coverity Scan CID 184086.
Thanks,
-Takahiro Akashi
Quoted 35 lines
Reported-by Tom Rini <[email protected]>Signed-off-by Heinrich Schuchardt <[email protected]>--- fs/fat/fat_write.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)fs/fat/fat_write.c +7
-1@@ -1263,6 +1263,11 @@ int fat_unlink(const char *filename)char *filename_copy, *dirname, *basename; filename_copy =strdup (filename); +if (!filename_copy) { +printf ("Error: allocating memory\n" ); + ret = -ENOMEM ; + goto exit; + }split_filename (filename_copy, &dirname, &basename);if (!strcmp (dirname,"/" ) && !strcmp (basename,"" )) {@@ -1274,7 +1279,8 @@ int fat_unlink(const char *filename) itr =malloc_cache_aligned (sizeof (fat_itr));if (!itr) {printf ("Error: allocating memory\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto exit; } ret =fat_itr_root (itr, &fsdata);Signature · 1 line
2.19.0
PATCH 1/1 fs: fat: memory leak in fat_unlink()
In reply to Heinrich SchuchardtQuoted 7 lines · Heinrich Schuchardt
Do not leak
filename_copyin case of error.
Catch out of memory when calling strdup.This addresses Coverity Scan CID 184086.
Reported-by Tom Rini <[email protected]>Signed-off-by Heinrich Schuchardt <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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/20181006/b58e7e47/attachment.sig>