From patchwork Sun Dec 12 16:58:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 5002 Return-path: Envelope-to: mchehab@gaivota Delivery-date: Sun, 12 Dec 2010 14:59:58 -0200 Received: from mchehab by gaivota with local (Exim 4.72) (envelope-from ) id 1PRpHC-0000Im-Eh for mchehab@gaivota; Sun, 12 Dec 2010 14:59:58 -0200 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.17) for (single-drop); Sun, 12 Dec 2010 14:59:58 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PRpFh-0007sV-AZ; Sun, 12 Dec 2010 16:58:25 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751861Ab0LLQ6W (ORCPT + 1 other); Sun, 12 Dec 2010 11:58:22 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:56958 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957Ab0LLQ6W (ORCPT ); Sun, 12 Dec 2010 11:58:22 -0500 Received: by wyb28 with SMTP id 28so5130991wyb.19 for ; Sun, 12 Dec 2010 08:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=z6Uhe7m0eSG8Tv3Bw/+0y2iLt0WDKvgULxtUTYGAlgA=; b=u0jDvhvHmZiPi1vzOt2nGzmQasM/m1d62xTsT0J83StcTRA3BuSt23o1XbcfBIv16t v650zK9efiKMYVZFThxXE4ND6zp6upJgRajyVRMMYh0JWd9cgdQFvL8U8nS28KKaZnwg KrIWo5FW+xOmnt+LwFpYL8oqoHzV61S1aoh3o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=sGA/qseG9c7hjWU9r+z/VShZSLroM6jhwDvBsxWE3QVrR7uan0c0up0ezsgSJ9oFIU hX5uIncCZXUaiMyPA+8NbH3bJSzx5jgQyg5GtAQMAFZmAm1VMvoGRlPkLVNubnQcI/6X nCWySVPTb8ydP3l4j+gjt/JENa+18OosCpDM0= Received: by 10.216.188.67 with SMTP id z45mr3608500wem.7.1292173099214; Sun, 12 Dec 2010 08:58:19 -0800 (PST) Received: from bicker (h2dd3.n1.ips.mtn.co.ug [41.210.173.211]) by mx.google.com with ESMTPS id t5sm148939wes.33.2010.12.12.08.58.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 12 Dec 2010 08:58:18 -0800 (PST) Date: Sun, 12 Dec 2010 19:58:12 +0300 From: Dan Carpenter To: Sergej Pupykin Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [patch v2] [media] bttv: take correct lock in bttv_open() Message-ID: <20101212165812.GG10623@bicker> References: <20101210033304.GX10623@bicker> <4D01D4BE.1080000@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4D01D4BE.1080000@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab We're trying to make sure that no one is writing to the btv->init struct while we copy it over to the newly allocated "fh" struct. The original code doesn't make sense because "fh->cap.vb_lock" hasn't been initialized and no one else can be writing to it anyway. Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=24602 Signed-off-by: Dan Carpenter --- Sergej could you test this one? -- 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/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index a529619..6c8f4b0 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c @@ -3302,9 +3302,9 @@ static int bttv_open(struct file *file) * Let's first copy btv->init at fh, holding cap.vb_lock, and then work * with the rest of init, holding btv->lock. */ - mutex_lock(&fh->cap.vb_lock); + mutex_lock(&btv->init.cap.vb_lock); *fh = btv->init; - mutex_unlock(&fh->cap.vb_lock); + mutex_unlock(&btv->init.cap.vb_lock); fh->type = type; fh->ov.setup_ok = 0;