From patchwork Fri Dec 17 16:07:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Philips X-Patchwork-Id: 416591 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBHGhIOE023121 for ; Fri, 17 Dec 2010 16:43:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753011Ab0LQQmt (ORCPT ); Fri, 17 Dec 2010 11:42:49 -0500 Received: from ifup.org ([198.145.64.140]:51276 "EHLO ifup.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980Ab0LQQmt (ORCPT ); Fri, 17 Dec 2010 11:42:49 -0500 Received: from localhost (c-71-56-137-246.hsd1.or.comcast.net [71.56.137.246]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ifup.org (Postfix) with ESMTPSA id 53D01251615B; Fri, 17 Dec 2010 07:49:10 -0800 (PST) Date: Fri, 17 Dec 2010 08:07:24 -0800 From: Brandon Philips To: Mauro Carvalho Chehab Cc: chris2553@googlemail.com, Torsten Kaiser , Dave Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Guennadi Liakhovetski Subject: Re: [PATCH] bttv: fix mutex use before init Message-ID: <20101217160723.GU2028@jenkins.home.ifup.org> References: <20101212131550.GA2608@darkstar> <20101214003024.GA3575@hanuman.home.ifup.org> <201012151844.04105.chris2553@googlemail.com> <4D093706.9040401@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4D093706.9040401@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Dec 2010 16:43:18 +0000 (UTC) diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 25e1ca0..0902ec0 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -2358,13 +2358,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, fh->ov.field = win->field; fh->ov.setup_ok = 1; - /* - * FIXME: btv is protected by btv->lock mutex, while btv->init - * is protected by fh->cap.vb_lock. This seems to open the - * possibility for some race situations. Maybe the better would - * be to unify those locks or to use another way to store the - * init values that will be consumed by videobuf callbacks - */ btv->init.ov.w.width = win->w.width; btv->init.ov.w.height = win->w.height; btv->init.ov.field = win->field; @@ -3219,15 +3212,6 @@ static int bttv_open(struct file *file) return -ENOMEM; file->private_data = fh; - /* - * btv is protected by btv->lock mutex, while btv->init and other - * streaming vars are protected by fh->cap.vb_lock. We need to take - * care of both locks to avoid troubles. However, vb_lock is used also - * inside videobuf, without calling buf->lock. So, it is a very bad - * idea to hold both locks at the same time. - * Let's first copy btv->init at fh, holding cap.vb_lock, and then work - * with the rest of init, holding btv->lock. - */ *fh = btv->init; fh->type = type; @@ -3302,10 +3286,6 @@ static int bttv_release(struct file *file) /* free stuff */ - /* - * videobuf uses cap.vb_lock - we should avoid holding btv->lock, - * otherwise we may have dead lock conditions - */ videobuf_mmap_free(&fh->cap); videobuf_mmap_free(&fh->vbi); v4l2_prio_close(&btv->prio, fh->prio);