mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Sean Young <sean@mess.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jarod Wilson <jarod@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v3 02/13] media: redrat3: Ensure rc device is freed if enable_detector() fails
Date: Wed, 22 Jul 2026 11:23:14 +0100	[thread overview]
Message-ID: <d5d7f661845474c2ca3686afd5ca2696742287f2.1784715737.git.sean@mess.org> (raw)
In-Reply-To: <cover.1784715737.git.sean@mess.org>

This particular error path does not free the rc device at all, with
its priv pointer still pointing at freed memory.

Fixes: 2154be651b90 ("[media] redrat3: new rc-core IR transceiver device driver")
Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/media/rc/redrat3.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 3f828a564e19..2b639fe59923 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -979,6 +979,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
 	struct usb_endpoint_descriptor *ep_narrow = NULL;
 	struct usb_endpoint_descriptor *ep_wide = NULL;
 	struct usb_endpoint_descriptor *ep_out = NULL;
+	struct rc_dev *rc = NULL;
 	u8 addr, attrs;
 	int pipe, i;
 	int retval = -ENOMEM;
@@ -1102,26 +1103,31 @@ static int redrat3_dev_probe(struct usb_interface *intf,
 	if (retval)
 		goto redrat_free;
 
-	rr3->rc = redrat3_init_rc_dev(rr3);
-	if (!rr3->rc) {
+	rc = redrat3_init_rc_dev(rr3);
+	if (!rc) {
 		retval = -ENOMEM;
 		goto led_free;
 	}
 
+	rr3->rc = rc;
+
 	/* might be all we need to do? */
 	retval = redrat3_enable_detector(rr3);
 	if (retval < 0)
-		goto led_free;
+		goto rc_free;
 
 	/* we can register the device now, as it is ready */
 	usb_set_intfdata(intf, rr3);
 
 	return 0;
 
+rc_free:
+	rc_unregister_device(rc);
 led_free:
 	led_classdev_unregister(&rr3->led);
 redrat_free:
 	redrat3_delete(rr3, rr3->udev);
+	rc_free_device(rc);
 
 no_endpoints:
 	return retval;
-- 
2.55.0


  parent reply	other threads:[~2026-07-22 10:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1784715737.git.sean@mess.org>
2026-07-22 10:23 ` [PATCH v3 01/13] media: streamzap: Add missing rc_unregister_device() Sean Young
2026-07-22 10:23 ` Sean Young [this message]
2026-07-22 10:23 ` [PATCH v3 03/13] media: redrat3: Ensure we don't read beyond the end of the packet Sean Young
2026-07-22 10:23 ` [PATCH v3 04/13] media: redrat3: Ensure all urbs are suspended Sean Young
2026-07-22 10:23 ` [PATCH v3 05/13] media: redrat3: Error path leaves device in transmitting state Sean Young
2026-07-22 10:23 ` [PATCH v3 06/13] media: sunxi-cir: Ensure no more interrupts can occur before free Sean Young
2026-07-22 10:23 ` [PATCH v3 07/13] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
2026-07-22 10:23 ` [PATCH v3 08/13] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
2026-07-22 10:23 ` [PATCH v3 09/13] media: meson-ir-tx: Ensure probe error is propagated Sean Young
2026-07-22 10:23 ` [PATCH v3 10/13] media: ir-hix5hd2: Ensure rdev is setup before interrupts are enabled Sean Young
2026-07-22 10:23 ` [PATCH v3 11/13] media: rc: Use after free in ir_raw_event_handle() Sean Young
2026-07-22 10:23 ` [PATCH v3 12/13] media: rc: Fix use after free in bpf progs Sean Young
2026-07-22 10:23 ` [PATCH v3 13/13] media: rc: Fix race condition during rc_register_device() Sean Young

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=d5d7f661845474c2ca3686afd5ca2696742287f2.1784715737.git.sean@mess.org \
    --to=sean@mess.org \
    --cc=jarod@redhat.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®