]> git.baikalelectronics.ru Git - kernel.git/commit
staging: greybus: loopback_test: Fix open error path
authorsayli karnik <karniksayli1995@gmail.com>
Mon, 20 Feb 2017 17:10:28 +0000 (22:40 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Mar 2017 08:17:01 +0000 (09:17 +0100)
commit610e5323e16142d5bd24b913a8504f3ac44485f6
tree199449c0227a231b167df6baf2b92f4568890c3c
parented2608576f1ae726915f0e0c053847cd181d1d2c
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>
drivers/staging/greybus/tools/loopback_test.c