* [PATCH] media: vidtv: fix time conversion error
@ 2020-09-16 19:05 Alex Dewar
0 siblings, 0 replies; only message in thread
From: Alex Dewar @ 2020-09-16 19:05 UTC (permalink / raw)
Cc: Alex Dewar, Daniel W. S. Almeida, Mauro Carvalho Chehab,
linux-media, linux-kernel
In vidtv_mux_check_mux_rate(), the function jiffies_to_usecs() is called
but its output is treated as if it were a value in milliseconds (indeed,
it is assigned to a variable called elapsed_time_msecs). Accordingly,
the calculation will be off by a factor of 1000. Fix this.
Addresses-Coverity: 1496996 ("Integer handling issues")
Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
drivers/media/test-drivers/vidtv/vidtv_mux.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_mux.c b/drivers/media/test-drivers/vidtv/vidtv_mux.c
index 5d1a275d504b..77b00a854a9c 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_mux.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_mux.c
@@ -349,12 +349,12 @@ static u32 vidtv_mux_check_mux_rate(struct vidtv_mux *m)
u64 nbytes_streamed; /* the number of bytes we actually wrote */
u32 num_null_pkts; /* number of null packets to bridge the gap */
- u64 elapsed_time_msecs = jiffies_to_usecs(m->timing.current_jiffies -
+ u64 elapsed_time_usecs = jiffies_to_usecs(m->timing.current_jiffies -
m->timing.past_jiffies);
- elapsed_time_msecs = min(elapsed_time_msecs, (u64)VIDTV_MAX_SLEEP_USECS / 1000);
- nbytes_expected = div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);
- nbytes_expected *= elapsed_time_msecs;
+ elapsed_time_usecs = min_t(u64, elapsed_time_usecs, VIDTV_MAX_SLEEP_USECS);
+ nbytes_expected = m->mux_rate_kbytes_sec; /* kb/sec is the same as bytes/msec */
+ nbytes_expected *= div64_u64(elapsed_time_usecs, 1000ULL);
nbytes_streamed = m->mux_buf_offset;
--
2.28.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-16 19:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 19:05 [PATCH] media: vidtv: fix time conversion error Alex Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®