Instead of using kalloc()/kfree(), use the new functions
media_entity_create()/media_entity_remove(), in order to
have the proper kref counts for the usage of the entity
objects at the media graph.

Signed-off-by: Mauro Carvalho Chehab <mche...@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 13bb57f0457f..9e0704118ffc 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -189,13 +189,14 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
        if (!dvbdev->adapter->mdev)
                return;
 
-       dvbdev->entity = kzalloc(sizeof(*dvbdev->entity), GFP_KERNEL);
+       dvbdev->entity = media_entity_create(dvbdev->adapter->mdev,
+                                            dvbdev->name, 0, NULL,
+                                            GFP_KERNEL);
        if (!dvbdev->entity)
                return;
 
        dvbdev->entity->info.dev.major = DVB_MAJOR;
        dvbdev->entity->info.dev.minor = minor;
-       dvbdev->entity->name = dvbdev->name;
 
        switch (type) {
        case DVB_DEVICE_CA:
@@ -214,7 +215,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
                dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads),
                                       GFP_KERNEL);
                if (!dvbdev->pads) {
-                       kfree(dvbdev->entity);
+                       media_entity_remove(dvbdev->entity);
                        return;
                }
        }
@@ -243,7 +244,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
                dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_NET;
                break;
        default:
-               kfree(dvbdev->entity);
+               media_entity_remove(dvbdev->entity);
                dvbdev->entity = NULL;
                return;
        }
@@ -258,7 +259,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
                        "%s: media_device_register_entity failed for %s\n",
                        __func__, dvbdev->entity->name);
                kfree(dvbdev->pads);
-               kfree(dvbdev->entity);
+               media_entity_remove(dvbdev->entity);
                dvbdev->entity = NULL;
                return;
        }
@@ -369,7 +370,7 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
        if (dvbdev->entity) {
                media_device_unregister_entity(dvbdev->entity);
-               kfree(dvbdev->entity);
+               media_entity_remove(dvbdev->entity);
                kfree(dvbdev->pads);
        }
 #endif
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to