linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: don't try to empty links list in media_entity_cleanup()
@ 2015-08-24 17:57 Javier Martinez Canillas
  2015-08-24 20:18 ` Javier Martinez Canillas
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Martinez Canillas @ 2015-08-24 17:57 UTC (permalink / raw)
  To: linux-media; +Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, linux-kernel

The media_entity_cleanup() function only cleans up the entity links list
but this operation is already made in media_device_unregister_entity().

In most cases this should be harmless (besides having duplicated code)
since the links list would be empty so the iteration would not happen
but the links list is initialized in media_device_register_entity() so
if a driver fails to register an entity with a media device and clean up
the entity in the error path, a NULL deference pointer error will happen.

So don't try to empty the links list in media_entity_cleanup() since
is either done already or haven't been initialized yet.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

---

 drivers/media/media-entity.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index fc6bb48027ab..acb65f734508 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -252,13 +252,6 @@ EXPORT_SYMBOL_GPL(media_entity_init);
 void
 media_entity_cleanup(struct media_entity *entity)
 {
-	struct media_link *link, *tmp;
-
-	list_for_each_entry_safe(link, tmp, &entity->links, list) {
-		media_gobj_remove(&link->graph_obj);
-		list_del(&link->list);
-		kfree(link);
-	}
 }
 EXPORT_SYMBOL_GPL(media_entity_cleanup);
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: don't try to empty links list in media_entity_cleanup()
  2015-08-24 17:57 [PATCH] media: don't try to empty links list in media_entity_cleanup() Javier Martinez Canillas
@ 2015-08-24 20:18 ` Javier Martinez Canillas
  0 siblings, 0 replies; 2+ messages in thread
From: Javier Martinez Canillas @ 2015-08-24 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Mauro Carvalho Chehab, linux-kernel

Hello,

On 08/24/2015 07:57 PM, Javier Martinez Canillas wrote:
> The media_entity_cleanup() function only cleans up the entity links list
> but this operation is already made in media_device_unregister_entity().
> 
> In most cases this should be harmless (besides having duplicated code)
> since the links list would be empty so the iteration would not happen
> but the links list is initialized in media_device_register_entity() so
> if a driver fails to register an entity with a media device and clean up
> the entity in the error path, a NULL deference pointer error will happen.
> 
> So don't try to empty the links list in media_entity_cleanup() since
> is either done already or haven't been initialized yet.
> 
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> 

I forgot to mention that this patch depends on Mauro's
"[PATCH v7 00/44] MC next generation patches" [0].

Sorry for missing that.

[0]: https://www.mail-archive.com/linux-media@vger.kernel.org/msg91528.html

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-24 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 17:57 [PATCH] media: don't try to empty links list in media_entity_cleanup() Javier Martinez Canillas
2015-08-24 20:18 ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).