dm: Fix various issues reported by coverity
cover dm: Fix various issues reported by coverity
A lot of issues have been found in the error handling with recent additions to the FIT handling code in mkimage. In some cases buffers are not freed or files are not closed. Fix these problems and a few others in existing code that coverity noticed due to recent patches.
Simon Glass (14):
mkimage: Fix munmap() call when importing data
mkimage: Correct file being closed twice in fit_import_data()
mkimage: Correct file being closed twice in fit_extract_data()
part_iso: Drop the customer unaligned access functions
part_efi: Drop the NULL check on dev_desc in part_print_efi()
part_efi: Drop NULL check in part_get_info_efi()
mkimage: Close the file when unable to get its size
mkimage: Add a missing free() to fit_import_data()
mkimage: Fix error path in fit_extract_data()
mkimage: Fix missing free() in fit_extract_data()
mkimage: Fix missing free() and close() in fit_build()
mkimage: Ensure file is closed in fdt_property_file()
mkimage: Don't close the file if it wasn't opened
usb: Correct return value in usb_stor_info()
common/usb_storage.c | 2 +- disk/part_efi.c | 6 +----- disk/part_iso.c | 27 ++++----------------------- tools/fit_image.c | 28 ++++++++++++++++++---------- tools/imagetool.c | 1 + 5 files changed, 25 insertions(+), 39 deletions(-)
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 1/14 mkimage: Fix munmap() call when importing data
The munmap() call unmaps the wrong memory buffer. Fix it.
---
tools/fit_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/fit_image.c +1 -1
@@ -517,7 +517,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) } } -munmap (fdt, sbuf.st_size); +munmap (old_fdt, sbuf.st_size);close (fd);/* Pack the FDT and place the data after it */
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 1/14 mkimage: Fix munmap() call when importing data
Quoted 5 lines · Simon Glass
The
munmap()call unmaps the wrong memory buffer. Fix it.Reported-by Coverity (CID: 138505)Reported-by Coverity (CID: 138495)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/4aca066f/attachment.sig>
PATCH 1/14 mkimage: Fix munmap() call when importing data
In reply to Simon GlassQuoted 6 lines · Simon Glass
The
munmap()call unmaps the wrong memory buffer. Fix it.Reported-by Coverity (CID: 138505)Reported-by Coverity (CID: 138495)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/ba716eba/attachment.sig>
PATCH 2/14 mkimage: Correct file being closed twice in fit_import_data()
In reply to Simon GlassThe code flows through to the end of the function, so we don't need another close() before this. Remove it.
---
tools/fit_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/fit_image.c +1 -1
@@ -530,6 +530,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)if (fd <0 ) {fprintf (stderr,"%s: Can't open %s: %s\n" , params->cmdname, fname,strerror (errno)); + ret = -EIO ; goto err; }if (write (fd, fdt, new_size) != new_size) {
@@ -538,7 +539,6 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) ret = -EIO ; goto err; } -close (fd); ret =0 ;
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 2/14 mkimage: Correct file being closed twice in fit_import_data()
Quoted 6 lines · Simon Glass
The code flows through to the end of the function, so we don't need another
close()before this. Remove it.Reported-by Coverity (CID: 138504)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/0ef2a812/attachment.sig>
PATCH 2/14 mkimage: Correct file being closed twice in fit_import_data()
In reply to Simon GlassQuoted 7 lines · Simon Glass
The code flows through to the end of the function, so we don't need another
close()before this. Remove it.Reported-by Coverity (CID: 138504)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/6970db11/attachment.sig>
PATCH 3/14 mkimage: Correct file being closed twice in fit_extract_data()
In reply to Simon GlassThe code flows through to the end of the function, so we don't need another close() before this. Remove it.
---
tools/fit_image.c | 2 -- 1 file changed, 2 deletions(-)
tools/fit_image.c +0 -2
@@ -446,8 +446,6 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EIO ; goto err; } -close (fd); - ret =0 ; err:
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 3/14 mkimage: Correct file being closed twice in fit_extract_data()
Quoted 6 lines · Simon Glass
The code flows through to the end of the function, so we don't need another
close()before this. Remove it.Reported-by Coverity (CID: 138503)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/2b3d51c5/attachment.sig>
PATCH 3/14 mkimage: Correct file being closed twice in fit_extract_data()
In reply to Simon GlassQuoted 7 lines · Simon Glass
The code flows through to the end of the function, so we don't need another
close()before this. Remove it.Reported-by Coverity (CID: 138503)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/0742f608/attachment.sig>
PATCH 4/14 part_iso: Drop the customer unaligned access functions
In reply to Simon GlassOne of these is causing a coverity warning. Drop these functions and use the standard U-Boot ones instead.
---
disk/part_iso.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
disk/part_iso.c +4 -23
@@ -7,6 +7,7 @@#include <common.h> #include <command.h> +#include <asm/unaligned.h> #include "part_iso.h" #ifdef HAVE_BLOCK_DEVICE
@@ -25,26 +26,6 @@static unsigned char tmpbuf[CD_SECTSIZE ]; -/* Convert char[4] in little endian format to the host format integer -*/ -static inline unsigned long le32_to_int (unsigned char *le32) -{ -return ((le32[3 ] <<24 ) + - (le32[2 ] <<16 ) + - (le32[1 ] <<8 ) + - le32[0 ] - ); -} -/* Convert char[2] in little endian format to the host format integer -*/ -static inline unsigned short le16_to_int (unsigned char *le16) -{ -return ((le16[1 ] <<8 ) + - le16[0 ] - ); -} - -/* only boot records will be listed as valid partitions */ int part_get_info_iso_verb (struct blk_desc *dev_desc,int part_num,disk_partition_t *info,int verb)
@@ -103,7 +84,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, pbr->ident_str, dev_desc->devnum, part_num);return (-1 ); } - bootaddr=le32_to_int (pbr->pointer); + bootaddr =get_unaligned_le32 (pbr->pointer);PRINTF (" Boot Entry at: %08lX\n" ,bootaddr);if (blk_dread (dev_desc, bootaddr,1 , (ulong *)tmpbuf) !=1 ) {if (verb)
@@ -203,7 +184,7 @@ found: }switch (pide->boot_media) {case 0x00 :/* no emulation */ - info->size=le16_to_int (pide->sec_cnt)>>2 ; + info->size =get_unaligned_le16 (pide->sec_cnt)>>2 ;break ;case 0x01 : info->size=2400 >>2 ;break ;/* 1.2MByte Floppy */ case 0x02 : info->size=2880 >>2 ;break ;/* 1.44MByte Floppy */
@@ -211,7 +192,7 @@ found:case 0x04 : info->size=2880 >>2 ;break ;/* dummy (HD Emulation) */ default : info->size=0 ;break ; } - newblkaddr=le32_to_int (pide->rel_block_addr); + newblkaddr =get_unaligned_le32 (pide->rel_block_addr); info->start=newblkaddr;PRINTF (" part %d found @ %lx size %lx\n" ,part_num,newblkaddr,info->size);return 0 ;
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 4/14 part_iso: Drop the customer unaligned access functions
Quoted 6 lines · Simon Glass
One of these is causing a coverity warning. Drop these functions and use the standard U-Boot ones instead.
Reported-by Coverity (CID: 138499)Signed-off-by Simon Glass <[email protected]>
... but the subject says customer not custom.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/b0375b27/attachment.sig>
PATCH 4/14 part_iso: Drop the customer unaligned access functions
In reply to Simon GlassQuoted 7 lines · Simon Glass
One of these is causing a coverity warning. Drop these functions and use the standard U-Boot ones instead.
Reported-by Coverity (CID: 138499)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/1c659e03/attachment.sig>
PATCH 5/14 part_efi: Drop the NULL check on dev_desc in part_print_efi()
In reply to Simon GlassThis cannot be NULL since part_print() calls this function and requires it to be non-NULL.
---
disk/part_efi.c | 4 ---- 1 file changed, 4 deletions(-)
disk/part_efi.c +0 -4
@@ -184,10 +184,6 @@ void part_print_efi(struct blk_desc *dev_desc)char uuid[37 ];unsigned char *uuid_bin; -if (!dev_desc) { -printf ("%s: Invalid Argument(s)\n" , __func__); -return ; - }/* This function validates AND fills in the GPT header and PTE */ if (is_gpt_valid (dev_desc,GPT_PRIMARY_PARTITION_TABLE_LBA , gpt_head, &gpt_pte) !=1 ) {
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 5/14 part_efi: Drop the NULL check on dev_desc in part_print_efi()
Quoted 5 lines · Simon Glass
This cannot be NULL since
part_print()calls this function and requires it to be non-NULL.Reported-by Coverity (CID: 138498)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/42efec48/attachment.sig>
PATCH 5/14 part_efi: Drop the NULL check on dev_desc in part_print_efi()
In reply to Simon GlassQuoted 6 lines · Simon Glass
This cannot be NULL since
part_print()calls this function and requires it to be non-NULL.Reported-by Coverity (CID: 138498)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/169c1427/attachment.sig>
PATCH 6/14 part_efi: Drop NULL check in part_get_info_efi()
In reply to Simon GlassThis cannot be NULL since part_get_info() calls this function and requires it to be non-NULL.
---
disk/part_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
disk/part_efi.c +1 -1
@@ -240,7 +240,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,gpt_entry *gpt_pte =NULL ;/* "part" argument must be at least 1 */ -if (!dev_desc || !info || part <1 ) { +if (part <1 ) {printf ("%s: Invalid Argument(s)\n" , __func__);return -1 ; }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 6/14 part_efi: Drop NULL check in part_get_info_efi()
Quoted 6 lines · Simon Glass
This cannot be NULL since
part_get_info()calls this function and requires it to be non-NULL.Reported-by Coverity (CID: 138497)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/64ca3b37/attachment.sig>
PATCH 6/14 part_efi: Drop NULL check in part_get_info_efi()
In reply to Simon GlassQuoted 7 lines · Simon Glass
This cannot be NULL since
part_get_info()calls this function and requires it to be non-NULL.Reported-by Coverity (CID: 138497)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/3c1c25ea/attachment.sig>
PATCH 7/14 mkimage: Close the file when unable to get its size
In reply to Simon GlassThere is a missing close() on the error path. Add it.
---
tools/imagetool.c | 1 + 1 file changed, 1 insertion(+)
tools/imagetool.c +1 -0
@@ -107,6 +107,7 @@ int imagetool_get_filesize(struct image_tool_params *params, const char *fname)if (fstat (fd, &sbuf) <0 ) {fprintf (stderr,"%s: Can't stat %s: %s\n" , params->cmdname, fname,strerror (errno)); +close (fd);return -1 ; }close (fd);
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 7/14 mkimage: Close the file when unable to get its size
Quoted 4 lines · Simon Glass
There is a missing
close()on the error path. Add it.Reported-by Coverity (CID: 138496)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/32b26755/attachment.sig>
PATCH 7/14 mkimage: Close the file when unable to get its size
In reply to Simon GlassQuoted 5 lines · Simon Glass
There is a missing
close()on the error path. Add it.Reported-by Coverity (CID: 138496)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/0e66ffe2/attachment.sig>
PATCH 8/14 mkimage: Add a missing free() to fit_import_data()
In reply to Simon GlassThe space allocated to fdt is not freed on error. Fix it.
---
tools/fit_image.c | 1 + 1 file changed, 1 insertion(+)
tools/fit_image.c +1 -0
@@ -541,6 +541,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) ret =0 ; err: +free (fdt);close (fd);return ret; }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 8/14 mkimage: Add a missing free() to fit_import_data()
Quoted 5 lines · Simon Glass
The space allocated to fdt is not freed on error. Fix it.
Reported-by Coverity (CID: 138494)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/55e2e2f9/attachment.sig>
PATCH 8/14 mkimage: Add a missing free() to fit_import_data()
In reply to Simon GlassQuoted 6 lines · Simon Glass
The space allocated to fdt is not freed on error. Fix it.
Reported-by Coverity (CID: 138494)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/1f92511b/attachment.sig>
PATCH 9/14 mkimage: Fix error path in fit_extract_data()
In reply to Simon GlassThe 'fdt' variable is not unmapped in all error cases. Fix this.
---
tools/fit_image.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/fit_image.c +7 -4
@@ -385,7 +385,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) buf =malloc (fit_size);if (!buf) { ret = -ENOMEM ; - goto err; + goto err_munmap; } buf_ptr =0 ;
@@ -393,7 +393,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)if (images <0 ) {debug ("%s: Cannot find /images node: %d\n" , __func__, images); ret = -EINVAL ; - goto err; + goto err_munmap; } for (node = fdt_first_subnode(fdt, images);
@@ -411,7 +411,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret =fdt_delprop (fdt, node,"data" );if (ret) { ret = -EPERM ; - goto err; + goto err_munmap; }fdt_setprop_u32 (fdt, node,"data-offset" , buf_ptr);fdt_setprop_u32 (fdt, node,"data-size" , len);
@@ -446,8 +446,11 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EIO ; goto err; } - ret =0 ; +close (fd); +return 0 ; +err_munmap: +munmap (fdt, sbuf.st_size); err:close (fd);return ret;
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 9/14 mkimage: Fix error path in fit_extract_data()
Quoted 5 lines · Simon Glass
The 'fdt' variable is not unmapped in all error cases. Fix this.
Reported-by Coverity (CID: 138493)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/dc884e3d/attachment.sig>
PATCH 9/14 mkimage: Fix error path in fit_extract_data()
In reply to Simon GlassQuoted 6 lines · Simon Glass
The 'fdt' variable is not unmapped in all error cases. Fix this.
Reported-by Coverity (CID: 138493)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/bf94f40d/attachment.sig>
PATCH 10/14 mkimage: Fix missing free() in fit_extract_data()
In reply to Simon GlassThe 'buf' variable is not freed. Fix it.
---
tools/fit_image.c | 2 ++ 1 file changed, 2 insertions(+)
tools/fit_image.c +2 -0
@@ -452,6 +452,8 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) err_munmap:munmap (fdt, sbuf.st_size); err: +if (buf) +free (buf);close (fd);return ret; }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 10/14 mkimage: Fix missing free() in fit_extract_data()
Quoted 4 lines · Simon Glass
The 'buf' variable is not freed. Fix it.
Reported-by Coverity (CID: 138492)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/f9bf4e36/attachment.sig>
PATCH 10/14 mkimage: Fix missing free() in fit_extract_data()
In reply to Simon GlassQuoted 5 lines · Simon Glass
The 'buf' variable is not freed. Fix it.
Reported-by Coverity (CID: 138492)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/40db93b1/attachment.sig>
PATCH 11/14 mkimage: Fix missing free() and close() in fit_build()
In reply to Simon GlassMake sure that both the error path and normal return free the buffer and close the file.
---
tools/fit_image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/fit_image.c +4 -1
@@ -329,7 +329,7 @@ static int fit_build(struct image_tool_params *params, const char *fname)if (ret <0 ) {fprintf (stderr,"%s: Failed to build FIT image\n" , params->cmdname); - goto err; + goto err_buf; } size = ret; fd =open (fname,O_RDWR |O_CREAT |O_TRUNC |O_BINARY ,0666 );
@@ -346,9 +346,12 @@ static int fit_build(struct image_tool_params *params, const char *fname) goto err; }close (fd); +free (buf);return 0 ; err: +close (fd); +err_buf:free (buf);return -1 ; }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 11/14 mkimage: Fix missing free() and close() in fit_build()
Quoted 5 lines · Simon Glass
Make sure that both the error path and normal return free the buffer and close the file.
Reported-by Coverity (CID: 138491)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/32435f7d/attachment.sig>
PATCH 11/14 mkimage: Fix missing free() and close() in fit_build()
In reply to Simon GlassQuoted 6 lines · Simon Glass
Make sure that both the error path and normal return free the buffer and close the file.
Reported-by Coverity (CID: 138491)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/12ca32e2/attachment.sig>
PATCH 12/14 mkimage: Ensure file is closed in fdt_property_file()
In reply to Simon GlassThe file that is opened is not closed in all cases. Fix it.
---
tools/fit_image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/fit_image.c +2 -1
@@ -123,13 +123,14 @@ static int fdt_property_file(struct image_tool_params *params, ret =fdt_property_placeholder (fdt,"data" , sbuf.st_size, &ptr);if (ret) -return ret; + goto err; ret =read (fd, ptr, sbuf.st_size);if (ret != sbuf.st_size) {fprintf (stderr,"%s: Can't read %s: %s\n" , params->cmdname, fname,strerror (errno)); goto err; } +close (fd);return 0 ; err:
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 12/14 mkimage: Ensure file is closed in fdt_property_file()
Quoted 4 lines · Simon Glass
The file that is opened is not closed in all cases. Fix it.
Reported-by Coverity (CID: 138490)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/6bf5a5dd/attachment.sig>
PATCH 12/14 mkimage: Ensure file is closed in fdt_property_file()
In reply to Simon GlassQuoted 5 lines · Simon Glass
The file that is opened is not closed in all cases. Fix it.
Reported-by Coverity (CID: 138490)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/8099caa6/attachment.sig>
PATCH 13/14 mkimage: Don't close the file if it wasn't opened
In reply to Simon GlassThe error path for fit_import_data() is incorrect if the second open() call fails.
---
tools/fit_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/fit_image.c +2 -2
@@ -537,8 +537,8 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)if (fd <0 ) {fprintf (stderr,"%s: Can't open %s: %s\n" , params->cmdname, fname,strerror (errno)); - ret = -EIO ; - goto err; +free (fdt); +return -EIO ; }if (write (fd, fdt, new_size) != new_size) { debug("%s: Failed to write external data to file %s\n",
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 13/14 mkimage: Don't close the file if it wasn't opened
Quoted 5 lines · Simon Glass
The error path for
fit_import_data()is incorrect if the secondopen()call fails.Reported-by Coverity (CID: 138489)Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/8a11333f/attachment.sig>
PATCH 13/14 mkimage: Don't close the file if it wasn't opened
In reply to Simon GlassQuoted 6 lines · Simon Glass
The error path for
fit_import_data()is incorrect if the secondopen()call fails.Reported-by Coverity (CID: 138489)Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/93552d29/attachment.sig>
PATCH 14/14 usb: Correct return value in usb_stor_info()
In reply to Simon GlassThis should return 0 on success, not 1. Fix it.
---
common/usb_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb_storage.c +1 -1
@@ -193,7 +193,7 @@ int usb_stor_info(void)return 1 ; } -return 1 ; +return 0 ; }static unsigned int usb_get_max_lun (struct us_data *us)
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 14/14 usb: Correct return value in usb_stor_info()
Quoted 3 lines · Simon Glass
This should return 0 on success, not 1. Fix it.
Signed-off-by Simon Glass <[email protected]>
Yikes. Thanks for finding this.
Quoted 19 lines
---
common/usb_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)common/usb_storage.c +1
-1@@ -193,7 +193,7 @@ int usb_stor_info(void)return 1 ; } -return 1 ; +return 0 ; }static unsigned int usb_get_max_lun (struct us_data *us)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 14/14 usb: Correct return value in usb_stor_info()
In reply to Simon GlassQuoted 3 lines · Simon Glass
This should return 0 on success, not 1. Fix it.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/a9a612bd/attachment.sig>
PATCH 14/14 usb: Correct return value in usb_stor_info()
In reply to Simon GlassQuoted 5 lines · Simon Glass
This should return 0 on success, not 1. Fix it.
Signed-off-by Simon Glass <[email protected]>Acked-by Marek Vasut <[email protected]>Reviewed-by Tom Rini <[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: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160322/03cf43d1/attachment.sig>