From patchwork Tue May 27 13:27:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 4249391 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BCF79F32B for ; Tue, 27 May 2014 13:28:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E6F120279 for ; Tue, 27 May 2014 13:28:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B359A201FE for ; Tue, 27 May 2014 13:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752530AbaE0N14 (ORCPT ); Tue, 27 May 2014 09:27:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:25540 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbaE0N1x (ORCPT ); Tue, 27 May 2014 09:27:53 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 27 May 2014 06:27:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,919,1392192000"; d="scan'208";a="538135743" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga001.fm.intel.com with ESMTP; 27 May 2014 06:27:51 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 2DA852009C; Tue, 27 May 2014 16:27:51 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id C9580200DE; Tue, 27 May 2014 16:27:49 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [PATCH 1/1] media: Set entity->links NULL in cleanup Date: Tue, 27 May 2014 16:27:49 +0300 Message-Id: <1401197269-18773-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Calling media_entity_cleanup() on a cleaned-up entity would result into double free of the entity->links pointer and likely memory corruption as well. Setting entity->links as NULL right after the kfree() avoids this. Signed-off-by: Sakari Ailus --- drivers/media/media-entity.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 37c334e..c404354 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -83,6 +83,7 @@ void media_entity_cleanup(struct media_entity *entity) { kfree(entity->links); + entity->links = NULL; } EXPORT_SYMBOL_GPL(media_entity_cleanup);