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(a)gmail.com>
---
v2:
Made the subject and changelog more concise
drivers/staging/greybus/tools/loopback_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
index 18d7a3d..2ee9a22 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;
}
--
2.7.4
[+CC: greybus and staging lists]
On Sat, Feb 18, 2017 at 01:47:38PM +0530, sayli karnik wrote:
> Change array index from the loop bound variable to loop index.
> The open_poll_files() functions attempts to open poll files of devices
> numbered from 0 to device_count. If the open() function inside it is
> unsuccessful for any intermediate device, all files with fds of devices from 0
> upto that device must be closed and open_poll_files() should return -1.
> The current code only closes the poll file with the most recent fd allocated,
> and in most cases tries to close the same file multiple times.
Nice catch!
You forgot to CC the relevant mailings lists however (use
scripts/get_maintainer.pl).
Also your patch summary is a bit too detailed, something like
staging: greybus: loopback_test: fix open error path
would be better.
Care to resend as a v2 with a shorter summary and lists on CC?
> Detected by coccinelle:
>
> @@
> expression arr,ex1,ex2;
> @@
>
> for(ex1 = 0; ex1 < ex2; ex1++) { <...
> arr[
> - ex2
> + ex1
> ]
> ...> }
>
> Signed-off-by: sayli karnik <karniksayli1995(a)gmail.com>
> ---
> drivers/staging/greybus/tools/loopback_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
> index 18d7a3d..2ee9a22 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;
> }
Thanks,
Johan
From: Colin Ian King <colin.king(a)canonical.com>
Currently newline.flow_control is uninitialized, so it can contain
any garbage from the stack. I believe it should be initialized with
GB_SERIAL_AUTO_RTSCTS_EN enabled if the termios c_cflag is CRTSCTS
enabled.
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
drivers/staging/greybus/uart.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 248ad66..b542f67 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -506,6 +506,8 @@ static void gb_tty_set_termios(struct tty_struct *tty,
newline.parity = termios->c_cflag & PARENB ?
(termios->c_cflag & PARODD ? 1 : 2) +
(termios->c_cflag & CMSPAR ? 2 : 0) : 0;
+ newline.flow_control = termios->c_cflag & CRTSCTS ?
+ GB_SERIAL_AUTO_RTSCTS_EN : 0;
switch (termios->c_cflag & CSIZE) {
case CS5:
--
2.10.2
The loopback driver allows the user to set a minimum delay of up to one
second to be inserted between test iterations (i.e. request
submissions). The delay is currently specified in microseconds and is
implemented using udelay.
Busy looping for long periods is not just anti-social; udelay must not
be used for delays longer than a few milliseconds due to the risk of
integer overflow.
Replace the broken udelay with a usleep_range with a 100 us range for
short delays (< 20 ms) and otherwise revert to using msleep.
Fixes: b36f04fa9417 ("greybus: loopback: Convert thread delay to
microseconds")
Signed-off-by: Johan Hovold <johan(a)kernel.org>
---
drivers/staging/greybus/loopback.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 6c2a41c638c3..a8329daf1e57 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -1061,8 +1061,13 @@ static int gb_loopback_fn(void *data)
gb_loopback_calculate_stats(gb, !!error);
}
gb->send_count++;
- if (us_wait)
- udelay(us_wait);
+
+ if (us_wait) {
+ if (us_wait < 20000)
+ usleep_range(us_wait, us_wait + 100);
+ else
+ msleep(us_wait / 1000);
+ }
}
gb_pm_runtime_put_autosuspend(bundle);
--
2.10.2