Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5667497iog; Thu, 23 Jun 2022 03:00:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tYfR/6cxz8SvU/jG81PXVZm7gpS5rrQ9DArged7q5LaYVpm4A/3q6Nr+VnubHx8SMMI72I X-Received: by 2002:a17:907:9805:b0:710:858f:ae0d with SMTP id ji5-20020a170907980500b00710858fae0dmr7152149ejc.360.1655978403616; Thu, 23 Jun 2022 03:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655978403; cv=none; d=google.com; s=arc-20160816; b=Mb4YGj42qUBT/d4crX7zHxwMhiumLjY+HTkb6rZDTug/mNx11j4GUhiBDCAPnDfEfI 30KRdN9x9iU15xekkGYZ27UCmGq2X+iGbSF0gQiHh2J0grpPZiKZ2gMKUEf7w3h7wXkZ Dh0/kI8PbNScIA2l2mk9mr9qHHI8pAsjR1BuBPFUr5LwcbsDLS3CVBaaKr9OZEcv9se/ kz6QNfoX7VdDlPObmjCNvKVzkP1wSXD5IDL/b9VgG3D7syhuLWHFfHhIfavuNJxeLe17 DUUdHMW1XbuU9Fjo36x8uz8gx/yZVFPqgm6QmdJj0kaGOk5yQrwfEsLxW8CFgyIDLlKU FqnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=I4ccaHhoovprD3iVhskXuHk/EsoG0EupnyPDdxO9s0o=; b=xLSPWVPCBr3mevOnwjbDx0VMQeNgOtw8ZUscw5LQdvLp9giZ+KAJp3on62Or6GJJ8T IfuUsZFSc3EN5iplWThU+en4UJcgIgz0oUbDy8zSGGuwJt09YfqnB5PGCQaZ7LIcOEPk Z6tJIGcNPBghP2OZf9AZdCAuvgekQSsVLr2T+AIt56ziLd7syg6e8r6oBnX74aM/eSU7 AC9Te7TYCvSV+xsIC+WspDNOFpzjRAaoHDxY0ulOdVW/KAG+ThV8xD3UlsZ20SUgX9kL KfI2T1NqLTO/9A1lfX9qeD+0Lo94qihwcmfNkL8osIHk8Rm5ubBI7VHw+U8XMtiXFFgd bdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jR2ZDFt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw5-20020a170906478500b00722d5ec7174si11675641ejc.823.2022.06.23.02.59.39; Thu, 23 Jun 2022 03:00:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jR2ZDFt/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbiFWJLz (ORCPT + 99 others); Thu, 23 Jun 2022 05:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiFWJLx (ORCPT ); Thu, 23 Jun 2022 05:11:53 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E4F036E18; Thu, 23 Jun 2022 02:11:51 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id k127so13317419pfd.10; Thu, 23 Jun 2022 02:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=I4ccaHhoovprD3iVhskXuHk/EsoG0EupnyPDdxO9s0o=; b=jR2ZDFt/AWjx+HZ/oGEGnMoHS6cydfh34+17sQGqE6zmiCYEneG6r5EyiLKJr/172z cnIy6Ahpxd1iqKKFC49j1jbet/UyBnduJZA6qKgQz3Kx0K4QExo95LLZ/yRnQV/071su Rq+KrArGkMRYmHnS+knp4x4GQQOXocPup0g2h6xIHaDSvjb4lATKbpNr+Y1uAngs2Eez yiEqS5YNKUYkSWEfeIj4jgYnkIWmyP0xmL8lQ2RbmssZGGLZ0w9/zlvHZYEgnu6WNslL jByCrORcNE/HlZkmPV8Vb0FuTxOhrdQ0m/TUSVCsAO0CKjYepOVzfAr98/j5Z1kPbwvc g1jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=I4ccaHhoovprD3iVhskXuHk/EsoG0EupnyPDdxO9s0o=; b=VuGi4iPlSh7pooZaAzyZ3KzWcBcT+DOFAAkMKztwVL8tK8EReVHWBzROY+9r7Xz+jJ dtdDQSjoJBaKchS544Q4xUNidmsLztg4c0XJlx6qesC5lPWRfdjDgh3iQ1ALTMi9Rzaq v3lyMOfqH708D292/FpVhfSeAZkkeiGo1ssTaijqdmNQ6oZlYA+Ic7EY39lDuy+Pv9c7 LYXbWdy+GQOAx9v4DCnUOiuEZ/TFKboEc88b6OXpzzPJiKY8jgfIxVX8Ha1xpLL+aYoe LKyKT+e7MMu20SP0BYm+/ji/zhv1CwXlgtltI0JDp59Am1ryu9JTOdgVZn6cTACZU0Ur HNcg== X-Gm-Message-State: AJIora/IcDe+6CwEv5vde5ikmkaZ5yF5KpFEJGW7uBOAEkaW8XDrH5o8 fkxGzPbRGmD3ueRmcYYtG8EUbC1bJppz3MthNRB3LwPF+Aa4UK1w X-Received: by 2002:a05:6a00:1591:b0:525:3b0d:85d7 with SMTP id u17-20020a056a00159100b005253b0d85d7mr11595458pfk.51.1655975510978; Thu, 23 Jun 2022 02:11:50 -0700 (PDT) MIME-Version: 1.0 References: <165590120140.1149771.2257818527859865760@Monstersaurus> <4883f0a7-6a1b-31bd-33fe-db8f6dcf73fa@selasky.org> In-Reply-To: <4883f0a7-6a1b-31bd-33fe-db8f6dcf73fa@selasky.org> From: =?UTF-8?B?7Jyg7Jqp7IiY?= Date: Thu, 23 Jun 2022 18:11:40 +0900 Message-ID: Subject: Re: [PATCH] media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c To: Hans Petter Selasky Cc: Kieran Bingham , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, mchehab@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Kieran Bingham I sent E-mail again by Linux terminal by using the command " ... git send-email .." I believe that you will surely get the diff file. Thank you 2022=EB=85=84 6=EC=9B=94 22=EC=9D=BC (=EC=88=98) =EC=98=A4=ED=9B=84 10:12, = Hans Petter Selasky =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > Hi Kieran, > > The consumed variable should not be negative. This bug has been there > since the beginning of the GIT at Linux from what I can see. > > +1 > > --HPS > > From 108c6acb2cc4bc4314b96f6f254a04b2873a096c Mon Sep 17 00:00:00 2001 > From: YongSu Yoo > Date: Sun, 22 May 2022 04:53:12 +0000 > Subject: [PATCH] media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c > > Signed-off-by:Yongsu Yoo > > 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 =3D (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % r= buf->size; > } > > - consumed =3D (idx - rbuf->pread) % rbuf->size; > + consumed =3D (idx - rbuf->pread); > + if (consumed < 0) > + consumed +=3D rbuf->size; > > while((dvb_ringbuffer_avail(rbuf) - consumed) > > DVB_RINGBUFFER_PKTHDRSIZE) { > > -- > 2.17.1