summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2018-03-14 13:45:36 +0900
committerPaweł Szewczyk <p.szewczyk@samsung.com>2018-04-06 15:53:31 +0200
commit6ad242f98a744df1ea258a340213ff688aad941e (patch)
tree0507c9a16669803615187dc3755eff89515fce0c
parent6c1256d6dd6e1b072453caf9f0a35becc2649261 (diff)
downloaddevice-manager-plugin-artik-6ad242f98a744df1ea258a340213ff688aad941e.tar.gz
device-manager-plugin-artik-6ad242f98a744df1ea258a340213ff688aad941e.tar.bz2
device-manager-plugin-artik-6ad242f98a744df1ea258a340213ff688aad941e.zip
usb_client: fix bug
Signed-off-by: INSUN PYO <insun.pyo@samsung.com> Change-Id: I70670d18ae5ae128ef0785ac79f220e3aa5c42b0 Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
-rw-r--r--hw/usb_client/usb_client.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/usb_client/usb_client.c b/hw/usb_client/usb_client.c
index f8bdd3a..df5229a 100644
--- a/hw/usb_client/usb_client.c
+++ b/hw/usb_client/usb_client.c
@@ -289,9 +289,12 @@ static int legacy_read_config(struct usb_gadget *gadget,
/* count number of functions in this config */
f_cnt = 1;
- for (i = 0; buf[i] != '\0'; ++i)
+ for (i = 0; buf[i] != '\0'; ++i) {
if (buf[i] == sep[0])
++f_cnt;
+ if (buf[i] == '\n') /* buf ends with it */
+ buf[i] = 0;
+ }
ret = legacy_alloc_config(f_cnt, &config);
if (ret)
@@ -305,7 +308,7 @@ static int legacy_read_config(struct usb_gadget *gadget,
if (!func) {
/* new function not added yet to gadget */
ret = legacy_alloc_new_func(gadget, fname, &func);
- if (!ret)
+ if (ret)
goto free_config;
}