Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4812599iog; Wed, 22 Jun 2022 06:25:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpg2jZBNIaAH7eESJMVnwjCkWddXtENa+gQzQEx9QMHr1/0mNBfY96uLn6izRWizjz/jxv X-Received: by 2002:a17:906:9750:b0:722:e84a:b6f2 with SMTP id o16-20020a170906975000b00722e84ab6f2mr3182229ejy.430.1655904304369; Wed, 22 Jun 2022 06:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655904304; cv=none; d=google.com; s=arc-20160816; b=O6ZUHQGS+vLFLhiQ7iRNk+8rOU72sbiFHa6+W2N/t2PILqzJvqIzJ7ysEAUzoS8XMP p7Ivrm8/fcL8HoesqdXKcPJQ8oRg091RO4mVtTM5Ss61/jIqtyC+NPtLVSyGJWdwiTw5 49+p4Zy5mQK1iJeAIAAGdTLa4rxBId0NICfC92C4G9X2fnUAfMRgTSmWPOwMx+biUvLa 76aBifrBDMKAzgy/USMGU7RarGfV2Q4FDuF5l0wyqYDO5wGSy2qoLKzaD1hC4j7ksbwp y/Hdrc1pOYegljpbNgSlFZvHqhpfC5VKraipX+HukhpFnw7pL5svB/DviS6I0cQb6ttl DpcQ== 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:to:content-language:subject:user-agent:mime-version:date :message-id; bh=CjA6sQ7KOLUiUb4h9gZ0cSn68dRnJKHghYvfrjcsrw8=; b=H5Gbyvcm0II2AHLS9Wj6l9BetHfs29cnN0MZKynTdFAQsI3BZzb5pA57aAca5CM8tp jdp2PRBrmx5kLSUkd5nTy+v5jQK3MuUqrUAAwdkoH/FBh6o7TFZaye4JkZM+vEHwUEgO XVVLcaM4P0ohDG+Qhg21li2AUd8+RkBc30J6IGL3ghLVg8ejVSWNNz0E3nxR2eYkpVKY GPH8eJfNtcLUsA1Kh/EEoqr5nIEpiG2xlDryeb9iDk/dGIBCDWrUloAmHtm5upjpttTN UFApCMlY7oeu9lKh6u9nulri+TyAgmFfQDS68Jmbj4ao16+fwtN0bmIReHgA2f45zuH3 /liA== 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 d13-20020a170906344d00b006fef89ab3besi860770ejb.729.2022.06.22.06.24.38; Wed, 22 Jun 2022 06:25:04 -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 S1354065AbiFVNVc (ORCPT + 99 others); Wed, 22 Jun 2022 09:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349975AbiFVNV1 (ORCPT ); Wed, 22 Jun 2022 09:21:27 -0400 X-Greylist: delayed 521 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 22 Jun 2022 06:21:24 PDT Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825AF3122C; Wed, 22 Jun 2022 06:21:24 -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 B9F7726021A; Wed, 22 Jun 2022 15:12:38 +0200 (CEST) Message-ID: <4883f0a7-6a1b-31bd-33fe-db8f6dcf73fa@selasky.org> Date: Wed, 22 Jun 2022 15:12:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c Content-Language: en-US To: Kieran Bingham , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, mchehab@kernel.org, =?UTF-8?B?7Jyg7Jqp7IiY?= References: <165590120140.1149771.2257818527859865760@Monstersaurus> From: Hans Petter Selasky In-Reply-To: <165590120140.1149771.2257818527859865760@Monstersaurus> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 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 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