From patchwork Tue Aug 14 06:58:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1318411 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 47FE43FC81 for ; Tue, 14 Aug 2012 06:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428Ab2HNG6a (ORCPT ); Tue, 14 Aug 2012 02:58:30 -0400 Received: from acsinet15.oracle.com ([141.146.126.227]:45576 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751950Ab2HNG6a (ORCPT ); Tue, 14 Aug 2012 02:58:30 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q7E6wMeS031033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 14 Aug 2012 06:58:23 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q7E6wMnI003180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Aug 2012 06:58:22 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q7E6wLlT023742; Tue, 14 Aug 2012 01:58:21 -0500 Received: from elgon.mountain (/41.212.103.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Aug 2012 23:58:21 -0700 Date: Tue, 14 Aug 2012 09:58:15 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Ezequiel Garcia , Hans Verkuil , Hans de Goede , Gianluca Gennari , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] [media] em28xx: use after free in em28xx_v4l2_close() Message-ID: <20120814065814.GB4791@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We need to move the unlock before the kfree(dev); Signed-off-by: Dan Carpenter --- Applies to linux-next. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index ecb23df..78d6ebd 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -2264,9 +2264,9 @@ static int em28xx_v4l2_close(struct file *filp) if (dev->state & DEV_DISCONNECTED) { em28xx_release_resources(dev); kfree(dev->alt_max_pkt_size); + mutex_unlock(&dev->lock); kfree(dev); kfree(fh); - mutex_unlock(&dev->lock); return 0; }