Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932811AbbHZPZs (ORCPT ); Wed, 26 Aug 2015 11:25:48 -0400 Received: from lists.s-osg.org ([54.187.51.154]:60101 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752860AbbHZPZq (ORCPT ); Wed, 26 Aug 2015 11:25:46 -0400 From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Laurent Pinchart , Shuah Khan , Javier Martinez Canillas Subject: [PATCH 1/2] [media] media: don't try to empty links list in media_entity_cleanup() Date: Wed, 26 Aug 2015 17:25:18 +0200 Message-Id: <1440602719-12500-2-git-send-email-javier@osg.samsung.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1440602719-12500-1-git-send-email-javier@osg.samsung.com> References: <1440602719-12500-1-git-send-email-javier@osg.samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1627 Lines: 45 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. Suggested-by: Mauro Carvalho Chehab Signed-off-by: Javier Martinez Canillas --- 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 7e6fb5a86b21..27eeb691765d 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/