summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus
diff options
context:
space:
mode:
authorsayli karnik <karniksayli1995@gmail.com>2017-02-20 22:40:28 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-06 09:17:01 +0100
commit6796cd84610a56beb7d3fa2818989727e4f26550 (patch)
tree199449c0227a231b167df6baf2b92f4568890c3c /drivers/staging/greybus
parentfea3860d7d69b0a82e0b96617258ffaf0ff250d4 (diff)
downloadblackbird-obmc-linux-6796cd84610a56beb7d3fa2818989727e4f26550.tar.gz
blackbird-obmc-linux-6796cd84610a56beb7d3fa2818989727e4f26550.zip
staging: greybus: loopback_test: Fix open error path
Change array index from the loop bound variable to loop index. If a poll file fails to open for any intermediate device, all poll files with fds of devices from 0 upto that device must be closed in the open_poll_files() function. The current code only closes the poll file with the most recent fd allocated, and at times tries to close the same file multiple times. Detected by coccinelle: @@ expression arr,ex1,ex2; @@ for(ex1 = 0; ex1 < ex2; ex1++) { <... arr[ - ex2 + ex1 ] ...> } Signed-off-by: sayli karnik <karniksayli1995@gmail.com> Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/greybus')
-rw-r--r--drivers/staging/greybus/tools/loopback_test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
index 1c01833d1f4e..f1edd4bc411e 100644
--- a/drivers/staging/greybus/tools/loopback_test.c
+++ b/drivers/staging/greybus/tools/loopback_test.c
@@ -674,7 +674,7 @@ static int open_poll_files(struct loopback_test *t)
err:
for (i = 0; i < fds_idx; i++)
- close(t->fds[fds_idx].fd);
+ close(t->fds[i].fd);
return -1;
}
OpenPOWER on IntegriCloud