aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-02-22 17:01:44 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-02-22 17:01:44 +0100
commitbf623fea2ef6ed0e5d2b381b1d66f08140fb1d78 (patch)
tree2b83e96cf6f77f51a07178e7cddac1648a741ec3
parentbf8d28efe5a3d2e17e33cb8c865286ffa76a819b (diff)
dvbv5-zap: don't use start time initialized
There's a possible condition that the start time would be used before its init: if dvb_dev_read() returns -EOVERFLOW when first == 1. In order to prevent that, initialize it eariler, while keeping the reset condition later on. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--utils/dvb/dvbv5-zap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 8420d99d..0462124a 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -557,6 +557,10 @@ static void copy_to_file(struct dvb_open_descriptor *in_fd, int out_fd,
long long int rc = 0LL;
struct timespec start, *elapsed;
+ /* Initialize start time, due to -EOVERFLOW with first == 1 */
+ if (clock_gettime(CLOCK_MONOTONIC, &start))
+ return NULL;
+
while (timeout_flag == 0) {
r = dvb_dev_read(in_fd, buf, sizeof(buf));
if (r < 0) {
@@ -580,6 +584,8 @@ static void copy_to_file(struct dvb_open_descriptor *in_fd, int out_fd,
* ensure that a program record will have the start amount of
* time specified by the user is to restart the timeout alarm
* here, after the first succeded read.
+ *
+ * So, let's reset the start time here.
*/
if (first) {
if (timeout > 0)

Privacy Policy