usb: gadget: dfu: discard dead code
PATCH 1/1 usb: gadget: dfu: discard dead code
Reported by Coverity:
Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement:
(f_dfu->strings + --i).s = ....
If calloc failed, i is still 0 and no need to call free, so discard the dead code.
--- drivers/usb/gadget/f_dfu.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/usb/gadget/f_dfu.c +1 -9
@@ -636,7 +636,7 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n) f_dfu->strings =calloc (sizeof (struct usb_string ), n +1 );if (!f_dfu->strings) - goto enomem; +return -ENOMEM ;for (i =0 ; i < n; ++i) { de =dfu_get_entity (i);
@@ -647,14 +647,6 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n) f_dfu->strings[i].s =NULL ;return 0 ; - -enomem: -while (i) - f_dfu->strings[--i].s =NULL ; - -free (f_dfu->strings); - -return -ENOMEM ; }static int dfu_prepare_function (struct f_dfu *f_dfu,int n)
Signature · 1 line
2.6.2
PATCH 1/1 usb: gadget: dfu: discard dead code
Quoted 11 lines · Peng Fan
Reported by Coverity:
Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement:
(f_dfu->strings+ --i).s = ....If calloc failed, i is still 0 and no need to call free, so discard the dead code.
Signed-off-by Peng Fan <[email protected]>Cc "?ukasz Majewski" <[email protected]>Cc Marek Vasut <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160503/2817cdbb/attachment.sig>
PATCH 1/1 usb: gadget: dfu: discard dead code
In reply to Peng FanHi Peng,
Quoted 33 lines
Reported by Coverity:
Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement:
(f_dfu->strings+ --i).s = ....If calloc failed, i is still 0 and no need to call free, so discard the dead code.
Signed-off-by Peng Fan <[email protected]>Cc "?ukasz Majewski" <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/usb/gadget/f_dfu.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/usb/gadget/f_dfu.c +1
-2@@ -636,7 +636,7 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n) f_dfu->strings =calloc (sizeof (struct usb_string ), n +1 );if (!f_dfu->strings) - goto enomem; +return -ENOMEM ;for (i =0 ; i < n; ++i) { de =dfu_get_entity (i);@@ -647,14 +647,6 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n) f_dfu->strings[i].s =NULL ;return 0 ; -
drivers/usb/gadget/f_dfu.c dfu_prepare_strings(struct f_dfu *f_dfu, int n) · line 652
Quoted 10 lines
drivers/usb/gadget/f_dfu.c +0
-7-enomem: -while (i) - f_dfu->strings[--i].s =NULL ; - -free (f_dfu->strings); - -return -ENOMEM ; }static int dfu_prepare_function (struct f_dfu *f_dfu,int n)
Applied to u-boot-dfu tree.
Tested-at: Odroid U3 (Exynos4412)
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group