* [PATCH] media: pvrusb2: Save the class device after registration
@ 2026-12-01 16:50 Yige Jiang
0 siblings, 0 replies; only message in thread
From: Yige Jiang @ 2026-12-01 16:50 UTC (permalink / raw)
To: Mike Isely, linux-media; +Cc: Yige Jiang, Mauro Carvalho Chehab, stable
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 16:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 16:50 [PATCH] media: pvrusb2: Save the class device after registration Yige Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox