From: Muhammad Bilal <meatuni001@gmail.com>
To: mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Muhammad Bilal <meatuni001@gmail.com>
Subject: [PATCH] media: dvb_ca_en50221: bail out of write loop on non-positive fraglen
Date: Sun, 20 Sep 2026 00:23:29 +0500 [thread overview]
Message-ID: <20260919192329.272325-1-meatuni001@gmail.com> (raw)
dvb_ca_en50221_io_write() derives fraglen from sl->link_buf_size, a
value negotiated with the CAM in dvb_ca_en50221_link_init() and only
ever clamped on the high end against HOST_LINK_BUF_SIZE. The loop
guards against a negative fraglen (link_buf_size < 2) but not against
fraglen == 0 (link_buf_size == 2 exactly): "fragpos += fraglen" at the
bottom of the loop then adds zero, so fragpos never reaches count and
the write() never returns while a positive count remains to be sent.
Treat a non-positive fraglen the same as a negative one and stop
fragmenting, consistent with how the existing check already handles
link_buf_size < 2.
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
---
drivers/media/dvb-core/dvb_ca_en50221.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 1b91ebb8f667..9131f62c1258 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1487,7 +1487,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
/* fragment the packets & store in the buffer */
while (fragpos < count) {
fraglen = sl->link_buf_size - 2;
- if (fraglen < 0)
+ if (fraglen <= 0)
break;
if (fraglen > HOST_LINK_BUF_SIZE - 2)
fraglen = HOST_LINK_BUF_SIZE - 2;
--
2.55.0
reply other threads:[~2026-09-19 19:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260919192329.272325-1-meatuni001@gmail.com \
--to=meatuni001@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®