From: Yige Jiang <yigejiang86@gmail.com>
To: Mike Isely <isely@pobox.com>, linux-media@vger.kernel.org
Cc: Yige Jiang <yigejiang86@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH] media: pvrusb2: Save the class device after registration
Date: Wed, 2 Dec 2026 00:50:35 +0800 [thread overview]
Message-ID: <20261201192850.b56218ce3236.pvrusb2@gmail.com> (raw)
class_dev_create() saves the new device in sfp->class_dev before
calling device_register(). On registration failure it drops the device
reference, but the saved pointer remains available to class_dev_destroy().
Assign sfp->class_dev after successful registration so that teardown
only acts on a registered device. Keep the existing puts on the error
path, including the one for the USB parent.
Fixes: 3117beec7e43 ("V4L/DVB (4316): Check __must_check warnings")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Compile-tested on arm64 with GCC 14.2 and W=1 against v7.4-rc5.
No hardware or runtime test was performed for this revision.
Earlier parent-reference fix: 02421d7278e4 (already in mainline).
drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
index 678e069b4c92..76f6aef16161 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
@@ -627,7 +627,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp)
class_dev->parent = get_device(&usb_dev->dev);
- sfp->class_dev = class_dev;
dev_set_drvdata(class_dev, sfp);
ret = device_register(class_dev);
if (ret) {
@@ -638,6 +637,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp)
return;
}
+ sfp->class_dev = class_dev;
sysfs_attr_init(&sfp->attr_v4l_minor_number.attr);
sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
reply other threads:[~2026-12-01 16:50 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=20261201192850.b56218ce3236.pvrusb2@gmail.com \
--to=yigejiang86@gmail.com \
--cc=isely@pobox.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.