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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  8 Aug 2016 21:30:40 +0200
From:	Robert Jarzmik <robert.jarzmik@...e.fr>
To:	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Guennadi Liakhovetski <g.liakhovetski@....de>,
	Jiri Kosina <trivial@...nel.org>,
	Hans Verkuil <hverkuil@...all.nl>
Cc:	linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
	Robert Jarzmik <robert.jarzmik@...e.fr>
Subject: [PATCH v3 02/14] media: mt9m111: prevent module removal while in use

The mt9m111 can be a removable module : the only case where the module
should be kept loaded is while it is used, ie. while an active
transation is ongoing on it.

The notion of active transaction is mapped on the power state of the
module : if powered on the removal is prohibited.

Signed-off-by: Robert Jarzmik <robert.jarzmik@...e.fr>
---
 drivers/media/i2c/soc_camera/mt9m111.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
index a7efaa5964d1..ea5b5e709402 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -780,23 +780,33 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 	struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
 	int ret;
 
+	if (!try_module_get(THIS_MODULE))
+		return -ENXIO;
+
 	ret = v4l2_clk_enable(mt9m111->clk);
 	if (ret < 0)
-		return ret;
+		goto out_module_put;
 
 	ret = mt9m111_resume(mt9m111);
 	if (ret < 0) {
 		dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
-		v4l2_clk_disable(mt9m111->clk);
+		goto out_clk_disable;
 	}
 
 	return ret;
+
+out_clk_disable:
+	v4l2_clk_disable(mt9m111->clk);
+out_module_put:
+	module_put(THIS_MODULE);
+	return ret;
 }
 
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
 	mt9m111_suspend(mt9m111);
 	v4l2_clk_disable(mt9m111->clk);
+	module_put(THIS_MODULE);
 }
 
 static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ