summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Fan <van.freenix@gmail.com>2016-05-03 10:25:22 +0800
committerMarek Vasut <marex@denx.de>2016-05-06 20:06:56 +0200
commit12ff19dbfd93abdb62b7b326fee3f5bfa659a75e (patch)
tree9de667e11fc40a911dd7b2ed1351347d0c905472
parent5d8fae79163e94671956c99654abf48cf49757ba (diff)
downloadu-boot-12ff19dbfd93abdb62b7b326fee3f5bfa659a75e.tar.gz
u-boot-12ff19dbfd93abdb62b7b326fee3f5bfa659a75e.tar.xz
u-boot-12ff19dbfd93abdb62b7b326fee3f5bfa659a75e.zip
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. Signed-off-by: Peng Fan <van.freenix@gmail.com> Cc: "Ɓukasz Majewski" <l.majewski@samsung.com> Cc: Marek Vasut <marex@denx.de>
-rw-r--r--drivers/usb/gadget/f_dfu.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 7d88008f74..8e7c981657 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -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)