lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 10 Sep 2009 19:29:07 +0000
From:	iceberg <strakh@...ras.ru>
To:	Jonathan Corbet <corbet@....net>, linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: Re: [PATCH] fix lock imbalances in /drivers/media/video/cafe_ccic.c

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@...ras.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);
 
 	/*

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ