diff mbox series

media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c

Message ID 20220623103543.4138-1-yongsuyoo0215@gmail.com (mailing list archive)
State New, archived
Headers show
Series media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c | expand

Commit Message

YongSu Yoo June 23, 2022, 10:35 a.m. UTC
Signed-off-by:Yongsu Yoo <yongsuyoo0215@gmail.com>

The function dvb_ringbuffer_pkt_next in
/linux-next/drviers/media/dvb-core/dvb_ringbuffer.c,
which searches the idx of the next valid packet in the ring
buffer of the ca->slot_info[slot].rx_buffer at
/linux-next/drivers/media/dvb-core/dvb_ca_en50221.c,
has the following problem.
In calculating the amounts of the consumed address of the ring
buffer, if the read address(rbuf->pread) of the ring buffer is
smaller than the idx, the amounts of the searched address
should be (idx - rbuf->pread),
whereas if the read address(rbuf->pread) of the ring buffer is
larger than the idx, the amounts of the consumed address should
be (idx - rbuf->pread + rbug->size). But there exists an
incorrect logic that the rbug-size was not properly added on
(idx - rbug->pread) in the later case. With this commit, we
fixed this bug.
---
 drivers/media/dvb-core/dvb_ringbuffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

YongSu Yoo June 26, 2022, 9:11 p.m. UTC | #1
Hi ~

How is this patch going ?
Can you share current status ?

Thank you


2022년 6월 23일 (목) 오후 7:35, YongSu Yoo <yongsuyoo0215@gmail.com>님이 작성:
>
> Signed-off-by:Yongsu Yoo <yongsuyoo0215@gmail.com>
>
> The function dvb_ringbuffer_pkt_next in
> /linux-next/drviers/media/dvb-core/dvb_ringbuffer.c,
> which searches the idx of the next valid packet in the ring
> buffer of the ca->slot_info[slot].rx_buffer at
> /linux-next/drivers/media/dvb-core/dvb_ca_en50221.c,
> has the following problem.
> In calculating the amounts of the consumed address of the ring
> buffer, if the read address(rbuf->pread) of the ring buffer is
> smaller than the idx, the amounts of the searched address
> should be (idx - rbuf->pread),
> whereas if the read address(rbuf->pread) of the ring buffer is
> larger than the idx, the amounts of the consumed address should
> be (idx - rbuf->pread + rbug->size). But there exists an
> incorrect logic that the rbug-size was not properly added on
> (idx - rbug->pread) in the later case. With this commit, we
> fixed this bug.
> ---
>  drivers/media/dvb-core/dvb_ringbuffer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c
> index d1d471af0636..7d4558de8e83 100644
> --- a/drivers/media/dvb-core/dvb_ringbuffer.c
> +++ b/drivers/media/dvb-core/dvb_ringbuffer.c
> @@ -335,7 +335,9 @@ ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t*
>                 idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
>         }
>
> -       consumed = (idx - rbuf->pread) % rbuf->size;
> +       consumed = (idx - rbuf->pread);
> +       if (consumed < 0)
> +               consumed += rbuf->size;
>
>         while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) {
>
> --
> 2.17.1
>
Hans Petter Selasky June 30, 2022, 1:42 p.m. UTC | #2
On 6/26/22 23:11, 유용수 wrote:
> Hi ~
> 
> How is this patch going ?
> Can you share current status ?
> 
> Thank you
> 

Hi Yongsu,

Linux guys can sometimes take a long time to include patches speaking 
weeks and months. For now I've added your patch to multimedia/webcamd 
(v5.17.1.1) which runs under FreeBSD 13.1 (not Linux).

https://github.com/hselasky/webcamd/commit/0e4d4959a2aea2e6a88d316eb943592fe0b23d09

--HPS
YongSu Yoo July 7, 2022, 8:36 a.m. UTC | #3
Dear Hans Petter Selasky
Thank you for your response and good advice and informations

Dear All
How is this patch going ?
Is there anyone who can share the current status ?

2022년 6월 30일 (목) 오후 10:42, Hans Petter Selasky <hps@selasky.org>님이 작성:
>
> On 6/26/22 23:11, 유용수 wrote:
> > Hi ~
> >
> > How is this patch going ?
> > Can you share current status ?
> >
> > Thank you
> >
>
> Hi Yongsu,
>
> Linux guys can sometimes take a long time to include patches speaking
> weeks and months. For now I've added your patch to multimedia/webcamd
> (v5.17.1.1) which runs under FreeBSD 13.1 (not Linux).
>
> https://github.com/hselasky/webcamd/commit/0e4d4959a2aea2e6a88d316eb943592fe0b23d09
>
> --HPS
YongSu Yoo July 25, 2022, 9:27 a.m. UTC | #4
Dear All

2 months have already passed since I sent the first E-mail.
Can you pay your attention to this patch ?
Can you take care of this patch ?

2022년 7월 7일 (목) 오후 5:36, 유용수 <yongsuyoo0215@gmail.com>님이 작성:
>
> Dear Hans Petter Selasky
> Thank you for your response and good advice and informations
>
> Dear All
> How is this patch going ?
> Is there anyone who can share the current status ?
>
> 2022년 6월 30일 (목) 오후 10:42, Hans Petter Selasky <hps@selasky.org>님이 작성:
> >
> > On 6/26/22 23:11, 유용수 wrote:
> > > Hi ~
> > >
> > > How is this patch going ?
> > > Can you share current status ?
> > >
> > > Thank you
> > >
> >
> > Hi Yongsu,
> >
> > Linux guys can sometimes take a long time to include patches speaking
> > weeks and months. For now I've added your patch to multimedia/webcamd
> > (v5.17.1.1) which runs under FreeBSD 13.1 (not Linux).
> >
> > https://github.com/hselasky/webcamd/commit/0e4d4959a2aea2e6a88d316eb943592fe0b23d09
> >
> > --HPS
diff mbox series

Patch

diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c
index d1d471af0636..7d4558de8e83 100644
--- a/drivers/media/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb-core/dvb_ringbuffer.c
@@ -335,7 +335,9 @@  ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t*
 		idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
 	}
 
-	consumed = (idx - rbuf->pread) % rbuf->size;
+	consumed = (idx - rbuf->pread);
+	if (consumed < 0)
+		consumed += rbuf->size;
 
 	while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) {