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:	Thu, 13 Jun 2013 20:20:50 +0200
From:	Andi Shyti <andi@...zian.org>
To:	arnd@...db.de, gregkh@...uxfoundation.org
Cc:	linux-kernel@...r.kernel.org, pc@...f.org, oatilla@...il.com,
	andi@...zian.org
Subject: [PATCH 16/19] bh1770glc: Added sanity check for scf

From: Onur Atilla <oatilla@...il.com>

Sensor compensation factor input from the platform
is being checked now before use.

Signed-off-by: Onur Atilla <oatilla@...il.com>
Signed-off-by: Andi Shyti <andi@...zian.org>
---
 drivers/misc/bh1770glc.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index cb63c25..383cefe 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -123,6 +123,7 @@
 #define BH1770_LUX_GA_SCALE		8192
 #define BH1770_LUX_CF_SCALE		8192 /* CF ChipFactor */
 #define BH1770_NEUTRAL_CF		BH1770_LUX_CF_SCALE
+#define BH1770_LUX_MAX_CF		(10 * BH1770_NEUTRAL_CF)
 #define BH1770_LUX_CORR_SCALE		4096
 
 #define PROX_ABOVE_THRESHOLD	1
@@ -550,7 +551,11 @@ static int bh1770_detect(struct bh1770_chip *chip)
 	if ((manu == BH1770_MANUFACT_ROHM) &&
 	    ((part & BH1770_PART_MASK) == BH1770_PART)) {
 		snprintf(chip->chipname, sizeof(chip->chipname), "BH1770GLC");
-		chip->lux_cf = chip->pdata->als_scf_BH1770;
+
+		/* apply sensor compensation factor only after verifying it */
+		if ((chip->pdata->als_scf_BH1770 > 0) &&
+			(chip->pdata->als_scf_BH1770 < BH1770_LUX_MAX_CF))
+			chip->lux_cf = chip->pdata->als_scf_BH1770;
 
 		/* apply minimum threshold value only after verifying it */
 		if ((chip->pdata->prox_min_thresh_BH1770 > 0) &&
@@ -565,7 +570,11 @@ static int bh1770_detect(struct bh1770_chip *chip)
 	if ((manu == BH1770_MANUFACT_OSRAM) &&
 	    ((part & BH1770_PART_MASK) == BH1770_PART)) {
 		snprintf(chip->chipname, sizeof(chip->chipname), "SFH7770");
-		chip->lux_cf = chip->pdata->als_scf_SFH7770;
+
+		/* apply sensor compensation factor only after verifying it */
+		if ((chip->pdata->als_scf_SFH7770 > 0) &&
+			(chip->pdata->als_scf_SFH7770 < BH1770_LUX_MAX_CF))
+			chip->lux_cf = chip->pdata->als_scf_SFH7770;
 
 		/* apply minimum threshold value only after verifying it */
 		if ((chip->pdata->prox_min_thresh_SFH7770 > 0) &&
-- 
1.7.10.4

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