From patchwork Thu Sep 10 19:29:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iceberg X-Patchwork-Id: 46620 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8AFSHGL003131 for ; Thu, 10 Sep 2009 15:28:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbZIJP1k (ORCPT ); Thu, 10 Sep 2009 11:27:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751840AbZIJP1j (ORCPT ); Thu, 10 Sep 2009 11:27:39 -0400 Received: from smtp.ispras.ru ([83.149.198.201]:53057 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbZIJP1j (ORCPT ); Thu, 10 Sep 2009 11:27:39 -0400 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id C49035D419F; Thu, 10 Sep 2009 18:54:16 +0400 (MSD) Received: from pamir.localnet (pamir.kazbek.ispras.ru [83.149.199.144]) by ispserv.ispras.ru (Postfix) with ESMTP id BC7573FC48; Thu, 10 Sep 2009 19:27:41 +0400 (MSD) Content-Disposition: inline From: iceberg Organization: ISP RAS To: Jonathan Corbet , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Re: [PATCH] fix lock imbalances in /drivers/media/video/cafe_ccic.c Date: Thu, 10 Sep 2009 19:29:07 +0000 User-Agent: KMail/1.10.3 (Linux/2.6.27.29-0.1-default; KDE/4.1.3; x86_64; ; ) MIME-Version: 1.0 Message-Id: <200909101929.08127.strakh@ispras.ru> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In ./drivers/media/video/cafe_ccic.c, in function cafe_pci_probe: Mutex must be unlocked before exit 1. On paths starting with mutex lock in line 1912, then continuing in lines: 1929, 1936 (goto unreg) and 1940 (goto iounmap) . 2. On path starting in line 1971 mutex lock, and then continuing in line 1978 (goto out_smbus) mutex. Fix lock imbalances in function cafe_pci_probe. Found by Linux Driver Verification project. Signed-off-by: Alexander Strakh --- -- 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/./a/drivers/media/video/cafe_ccic.c b/./b/drivers/media/video/cafe_ccic.c index c4d181d..2987433 100644 --- a/./a/drivers/media/video/cafe_ccic.c +++ b/./b/drivers/media/video/cafe_ccic.c @@ -1925,19 +1925,24 @@ static int cafe_pci_probe(struct pci_dev *pdev, * Get set up on the PCI bus. */ ret = pci_enable_device(pdev); - if (ret) + if (ret) { + mutex_unlock(&cam->s_mutex); goto out_unreg; + } pci_set_master(pdev); ret = -EIO; cam->regs = pci_iomap(pdev, 0, 0); if (! cam->regs) { printk(KERN_ERR "Unable to ioremap cafe-ccic regs\n"); + mutex_unlock(&cam->s_mutex); goto out_unreg; } ret = request_irq(pdev->irq, cafe_irq, IRQF_SHARED, "cafe-ccic", cam); - if (ret) + if (ret) { + mutex_unlock(&cam->s_mutex); goto out_iounmap; + } /* * Initialize the controller and leave it powered up. It will * stay that way until the sensor driver shows up. @@ -1974,8 +1979,10 @@ static int cafe_pci_probe(struct pci_dev *pdev, /* cam->vdev.debug = V4L2_DEBUG_IOCTL_ARG;*/ cam->vdev.v4l2_dev = &cam->v4l2_dev; ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1); - if (ret) + if (ret) { + mutex_unlock(&cam->s_mutex); goto out_smbus; + } video_set_drvdata(&cam->vdev, cam); /*