From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Qianfeng Rong <rongqianfeng@vivo.com>, Sean Young <sean@mess.org>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
Sasha Levin <sashal@kernel.org>,
linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-5.4] media: redrat3: use int type to store negative error codes
Date: Sat, 25 Oct 2025 11:57:45 -0400 [thread overview]
Message-ID: <20251025160905.3857885-234-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>
From: Qianfeng Rong <rongqianfeng@vivo.com>
[ Upstream commit ecba852dc9f4993f4f894ea1f352564560e19a3e ]
Change "ret" from u8 to int type in redrat3_enable_detector() to store
negative error codes or zero returned by redrat3_send_cmd() and
usb_submit_urb() - this better aligns with the coding standards and
maintains code consistency.
No effect on runtime.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes
- Prevents truncation of negative error codes in
`redrat3_enable_detector()`. Previously `ret` was `u8`, so failures
from `usb_submit_urb()` (negative errno) would wrap to a positive
byte (e.g., `-EPIPE` → `224`), causing the caller to treat failures
as success.
- The caller checks only for negative returns: `retval =
redrat3_enable_detector(rr3); if (retval < 0) ...` in
`drivers/media/rc/redrat3.c:1114-1116`. With a `u8` `ret`, errors
would be lost, the probe would continue, and the device could end up
non-functional (URBs not running) while the driver reports success.
- Evidence in code
- `redrat3_send_cmd()` returns negative errno or non-negative status;
it’s already `int`: `drivers/media/rc/redrat3.c:394-419`.
- The patch changes `ret` to `int` in the detector enable path:
`drivers/media/rc/redrat3.c:425`.
- URB submissions return negative errno on error; these are assigned
to and returned via `ret`: `drivers/media/rc/redrat3.c:439-443`,
`drivers/media/rc/redrat3.c:445-449`. With `ret` as `u8`, a negative
error like `-EPIPE` becomes a large positive and bypasses the `< 0`
check at the call site (`drivers/media/rc/redrat3.c:1114-1116`).
- Scope and risk
- Minimal, localized change (1 line, one function, single driver).
- No API/ABI change; no behavior change on success paths; only
corrects error propagation.
- Aligns with kernel conventions where error codes are negative
`int`s; the rest of this driver already uses `int ret` broadly
(e.g., `drivers/media/rc/redrat3.c:503`,
`drivers/media/rc/redrat3.c:657`, `drivers/media/rc/redrat3.c:691`,
etc.), improving consistency.
- Stable backport criteria
- Fixes a real, user-visible bug (driver may “succeed” initialization
while URBs failed, leading to non-working IR receive).
- Small and contained; no architectural change; regression risk is
very low.
- Not a feature addition; strictly a correctness fix for error
handling.
Given the clear correctness improvement, minimal risk, and user impact
on failure paths, this commit is a good candidate for stable backport.
drivers/media/rc/redrat3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index d89a4cfe3c895..a49173f54a4d0 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -422,7 +422,7 @@ static int redrat3_send_cmd(int cmd, struct redrat3_dev *rr3)
static int redrat3_enable_detector(struct redrat3_dev *rr3)
{
struct device *dev = rr3->dev;
- u8 ret;
+ int ret;
ret = redrat3_send_cmd(RR3_RC_DET_ENABLE, rr3);
if (ret != 0)
--
2.51.0
next prev parent reply other threads:[~2025-10-25 16:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17] media: nxp: imx8-isi: Fix streaming cleanup on release Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: improve dma-resv handling for backup object Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Only validate format in querystd Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.6] media: ov08x40: Fix the horizontal flip control Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.15] media: em28xx: add special case for legacy gpiolib interface Sasha Levin
2025-10-27 9:24 ` Arnd Bergmann
2025-11-04 13:55 ` Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Do not write format to device in set_fmt Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] media: imx-mipi-csis: Only set clock rate when specified in DT Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] media: qcom: camss: csiphy-3ph: Add CSIPHY 2ph DPHY v2.0.1 init sequence Sasha Levin
2025-10-25 15:57 ` Sasha Levin [this message]
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: pci: ivtv: Don't create fake v4l2_fh Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: imon: make send_packet() more robust Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Add missing lock in suspend callback Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: verisilicon: Explicitly disable selection api ioctls for decoders Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: pci: mgb4: Fix timings comparison in VIDIOC_S_DV_TIMINGS Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: ipu6: isys: Set embedded data type correctly for metadata formats Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: i2c: og01a1b: Specify monochrome media bus format instead of Bayer Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.1] media: amphion: Delete v4l2_fh synchronously in .release() Sasha Levin
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=20251025160905.3857885-234-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=rongqianfeng@vivo.com \
--cc=sean@mess.org \
--cc=stable@vger.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