public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: iceberg <strakh@ispras.ru>
To: Jonathan Corbet <corbet@lwn.net>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fix lock imbalances in /drivers/media/video/cafe_ccic.c
Date: Thu, 10 Sep 2009 18:37:34 +0000	[thread overview]
Message-ID: <200909101837.34472.strakh@ispras.ru> (raw)

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 <strakh@ispras.ru>

---
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);

        /*


             reply	other threads:[~2009-09-10 15:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10 18:37 iceberg [this message]
2009-09-10 14:48 ` [PATCH] fix lock imbalances in /drivers/media/video/cafe_ccic.c Daniel Walker
2009-09-10 15:30 ` Jonathan Corbet
2009-09-10 19:05   ` Steven Rostedt
2009-09-11 17:47   ` iceberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200909101837.34472.strakh@ispras.ru \
    --to=strakh@ispras.ru \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox