Skip to content

Commit

Permalink
V4L/DVB: pvrusb2: Fix USB parent device reference count
Browse files Browse the repository at this point in the history
pvrusb2: Correctly reference count pointer to parent USB device when linked
from sysfs interface.  This is technically a pretty nasty problem,
however as far as I know nobody had been getting burned by it (yet).

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mike Isely authored and Mauro Carvalho Chehab committed Jun 1, 2010
1 parent d72baad commit 28c4a5e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/media/video/pvrusb2/pvrusb2-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ static void pvr2_sysfs_release(struct device *class_dev)

static void class_dev_destroy(struct pvr2_sysfs *sfp)
{
struct device *dev;
if (!sfp->class_dev) return;
#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
pvr2_sysfs_tear_down_debugifc(sfp);
Expand Down Expand Up @@ -542,6 +543,9 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
}
pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev);
dev_set_drvdata(sfp->class_dev, NULL);
dev = sfp->class_dev->parent;
sfp->class_dev->parent = NULL;
put_device(dev);
device_unregister(sfp->class_dev);
sfp->class_dev = NULL;
}
Expand Down Expand Up @@ -631,10 +635,11 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
pvr2_sysfs_trace("Creating class_dev id=%p",class_dev);

class_dev->class = &class_ptr->class;

dev_set_name(class_dev, "%s",
pvr2_hdw_get_device_identifier(sfp->channel.hdw));

class_dev->parent = &usb_dev->dev;
class_dev->parent = get_device(&usb_dev->dev);

sfp->class_dev = class_dev;
dev_set_drvdata(class_dev, sfp);
Expand Down Expand Up @@ -775,7 +780,8 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
struct pvr2_sysfs_class *clp;
clp = kzalloc(sizeof(*clp),GFP_KERNEL);
if (!clp) return clp;
pvr2_sysfs_trace("Creating pvr2_sysfs_class id=%p",clp);
pvr2_sysfs_trace("Creating and registering pvr2_sysfs_class id=%p",
clp);
clp->class.name = "pvrusb2";
clp->class.class_release = pvr2_sysfs_class_release;
clp->class.dev_release = pvr2_sysfs_release;
Expand All @@ -791,6 +797,7 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)

void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *clp)
{
pvr2_sysfs_trace("Unregistering pvr2_sysfs_class id=%p", clp);
class_unregister(&clp->class);
}

Expand Down

0 comments on commit 28c4a5e

Please sign in to comment.