Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2069356rwn; Fri, 9 Sep 2022 08:06:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tY3Va7qTSHdkpvLglevb1gC8txFOwAShVXmavBqYLan4fb6BvlXATTX0IGvtl4iLSLpac X-Received: by 2002:a17:906:c10:b0:6f4:6c70:b00f with SMTP id s16-20020a1709060c1000b006f46c70b00fmr10480447ejf.660.1662736016468; Fri, 09 Sep 2022 08:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662736016; cv=none; d=google.com; s=arc-20160816; b=0tA+jMWZt0XzBj4mKIlSpObK530N22ScAyKRXlxzkl0CVK3wI+NsUqNal4gQQjjQIH 8rTo1q7TcpF9vj707GyDPIxf02WO3BkSw61li9nNcylnVXXVVu+y6jDpjCka+ljEhiyx kVCdsprcG3qlZTLNMlVym7F9r3nNsTwl+AFKeJjFd2sA8swWMQHDQb6hbnec5vLAyRAQ 8v5TTqFWJR+YvXEw25x0HdPbn8hxKexYLs+S6mjQK/4TZLJmFKcyqpeDjzJI2GDT8Z0p S9Si60AoX3EGeEqDGRLBoX92eP7PbCU44+pb9sar0ciqP7kxxfpq1nQkzX11WgQOKTuR il3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=WGfQyBBwN1RfsZnukzYBwD2SmKfw3bZlwi5Vs1Blrsk=; b=Hd+2jDEvtRoOhTk2coX4K3DY5e4LCbdIAOtdVeXFJWIxL+ZEm2ELwcjWiUi2ymm2yD mkDlRy/OJrPZG5yiJrj85VCT30GU9/sj3QynKH4U15asvDvPVvhmKMGA6b9TJ4cE9mQf PqhKC4pY9KS9FWOkywH0qd3lnMjSAEBHsPm+T4oduIcFZy5pkT6MZAYZc1tiq2t+drwn ou2RZpbM4E3hk/c+Vd9qAyFKg+UX0uFf0idnYOZ13S4yKoA4VBR5/TdhIKZ3v/Mu1bSM Pgw/QdksQ4rTG4fXS94mdbsDLz1Eo2sX1E/+UC1AtTMMLwzVVNDzZPkUM54zzGzVeprt eiqQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf35-20020a1709077f2300b0073d9b03865asi453096ejc.706.2022.09.09.08.06.30; Fri, 09 Sep 2022 08:06:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiIIOyw (ORCPT + 99 others); Fri, 9 Sep 2022 10:54:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbiIIOyt (ORCPT ); Fri, 9 Sep 2022 10:54:49 -0400 X-Greylist: delayed 504 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 09 Sep 2022 07:54:45 PDT Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E6A5590; Fri, 9 Sep 2022 07:54:44 -0700 (PDT) Received: from [10.36.2.165] (unknown [178.232.223.95]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 239F02600FB; Fri, 9 Sep 2022 16:46:16 +0200 (CEST) Message-ID: <085b9025-bc23-37d4-d430-afc432b4d783@selasky.org> Date: Fri, 9 Sep 2022 16:46:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c Content-Language: en-US To: =?UTF-8?B?7Jyg7Jqp7IiY?= , Kieran Bingham , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab@kernel.org Cc: 0215yys@hanmail.net References: <165590120140.1149771.2257818527859865760@Monstersaurus> <4883f0a7-6a1b-31bd-33fe-db8f6dcf73fa@selasky.org> From: Hans Petter Selasky In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 On 8/31/22 15:45, 유용수 wrote: > Dear All, > > Can you share how this patch is going ? > > 2022년 8월 18일 (목) 오후 9:55, 유용수 님이 작성: >> >> Dear All, >> >> Can you pay your attention to this patch ? >> This is a very simple modification. >> But, too much time has already passed since I sent the first E-mail. >> >> 2022년 8월 3일 (수) 오후 9:04, 유용수 님이 작성: >>> >>> Dear All. >>> Too much time has already passed since I first sent this Email. >>> Can you share how this patch is going ? >>> >>> 2022년 6월 23일 (목) 오후 6:11, 유용수 님이 작성: >>>> >>>> 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년 6월 22일 (수) 오후 10:12, Hans Petter Selasky 님이 작성: >>>>> >>>>> 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 = (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 Maybe it will help if you write a test C-program to show the bad numbers computed? --HPS