Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf Signed-off-by: Stanislaw Wadas <s.wadas@xxxxxxxxxxx> --- src/gadget.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGTH, fp); + if (ret == NULL) { + ERROR("read error"); + fclose(fp); + return ret; + } fclose(fp); @@ -127,6 +132,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) { char p[MAX_LENGTH]; FILE *fp; + int ret; sprintf(p, "%s/%s/%s", path, name, file); @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR("write error"); + fclose(fp); + return; + } fclose(fp); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html