All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1] regulator: pv88090: Exception handling for out of bounds
@ 2017-08-30  8:54 Eric Jeong
  2017-08-30 15:12 ` Mark Brown
  2017-08-30 15:23 ` Applied "regulator: pv88090: Exception handling for out of bounds" to the regulator tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Jeong @ 2017-08-30  8:54 UTC (permalink / raw)
  To: LINUXKERNEL, Liam Girdwood, Mark Brown; +Cc: Support Opensource


From: Eric Jeong <eric.jeong.opensource@diasemi.com>

This is a patch for exception handlding that the index of array is
out of bounds. And the definitions have been updated to use
proper device name.

Signed-off-by: Eric Jeong <eric.jeong.opensource@diasemi.com>

---
This patch applies against linux-next and next-20170829 


 drivers/regulator/pv88090-regulator.c |   11 ++++++++---
 drivers/regulator/pv88090-regulator.h |    8 ++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c
index ab51e25..7a0c159 100644
--- a/drivers/regulator/pv88090-regulator.c
+++ b/drivers/regulator/pv88090-regulator.c
@@ -43,7 +43,7 @@ enum {
 struct pv88090_regulator {
 	struct regulator_desc desc;
 	/* Current limiting */
-	unsigned	n_current_limits;
+	unsigned int n_current_limits;
 	const int	*current_limits;
 	unsigned int limit_mask;
 	unsigned int conf;
@@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c,
 				return ret;
 
 			range = (range >>
-				 (PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
-				PV88080_BUCK_VRANGE_GAIN_MASK;
+				 (PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
+				PV88090_BUCK_VRANGE_GAIN_MASK;
 			index = ((range << 1) | conf2);
+			if (index > PV88090_ID_BUCK3) {
+				dev_err(chip->dev,
+					"Invalid index(%d)\n", index);
+				return -EINVAL;
+			}
 
 			pv88090_regulator_info[i].desc.min_uV
 				= pv88090_buck_vol[index].min_uV;
diff --git a/drivers/regulator/pv88090-regulator.h b/drivers/regulator/pv88090-regulator.h
index d7aca8d..62d9029 100644
--- a/drivers/regulator/pv88090-regulator.h
+++ b/drivers/regulator/pv88090-regulator.h
@@ -89,10 +89,10 @@
 #define PV88090_BUCK_VDAC_RANGE_2			0x01
 
 /* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */
-#define PV88080_BUCK_VRANGE_GAIN_SHIFT			3
-#define PV88080_BUCK_VRANGE_GAIN_MASK			0x01
+#define PV88090_BUCK_VRANGE_GAIN_SHIFT			3
+#define PV88090_BUCK_VRANGE_GAIN_MASK			0x01
 
-#define PV88080_BUCK_VRANGE_GAIN_1			0x00
-#define PV88080_BUCK_VRANGE_GAIN_2			0x01
+#define PV88090_BUCK_VRANGE_GAIN_1			0x00
+#define PV88090_BUCK_VRANGE_GAIN_2			0x01
 
 #endif	/* __PV88090_REGISTERS_H__ */
-- 
end-of-patch for PATCH V1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V1] regulator: pv88090: Exception handling for out of bounds
  2017-08-30  8:54 [PATCH V1] regulator: pv88090: Exception handling for out of bounds Eric Jeong
@ 2017-08-30 15:12 ` Mark Brown
  2017-08-30 15:23 ` Applied "regulator: pv88090: Exception handling for out of bounds" to the regulator tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-08-30 15:12 UTC (permalink / raw)
  To: Eric Jeong; +Cc: LINUXKERNEL, Liam Girdwood, Support Opensource

[-- Attachment #1: Type: text/plain, Size: 832 bytes --]

On Wed, Aug 30, 2017 at 05:54:27PM +0900, Eric Jeong wrote:

I've applied this but a few things to bear in mind for future
submissions:

> From: Eric Jeong <eric.jeong.opensource@diasemi.com>

Please try to ensure that your e-mail address matches the one you use
for signoff, this avoids your mail looking like a non-author send that's
missing a signoff.

> This is a patch for exception handlding that the index of array is
> out of bounds. And the definitions have been updated to use
> proper device name.

This'd be easier to review with the rename separated out from the
functional change.

> @@ -43,7 +43,7 @@ enum {
>  struct pv88090_regulator {
>  	struct regulator_desc desc;
>  	/* Current limiting */
> -	unsigned	n_current_limits;
> +	unsigned int n_current_limits;

This is fine but it's an unrelated stylistic change.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "regulator: pv88090: Exception handling for out of bounds" to the regulator tree
  2017-08-30  8:54 [PATCH V1] regulator: pv88090: Exception handling for out of bounds Eric Jeong
  2017-08-30 15:12 ` Mark Brown
@ 2017-08-30 15:23 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-08-30 15:23 UTC (permalink / raw)
  To: Eric Jeong
  Cc: Mark Brown, LINUXKERNEL, Liam Girdwood, Mark Brown,
	Support Opensource, linux-kernel

The patch

   regulator: pv88090: Exception handling for out of bounds

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 8986a11978373400a7e880b413c43ca229d7a8a8 Mon Sep 17 00:00:00 2001
From: Eric Jeong <eric.jeong.opensource@diasemi.com>
Date: Wed, 30 Aug 2017 17:54:27 +0900
Subject: [PATCH] regulator: pv88090: Exception handling for out of bounds

This is a patch for exception handlding that the index of array is
out of bounds. And the definitions have been updated to use
proper device name.

Signed-off-by: Eric Jeong <eric.jeong.opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/pv88090-regulator.c | 11 ++++++++---
 drivers/regulator/pv88090-regulator.h |  8 ++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c
index ab51e254d13a..7a0c15957bd0 100644
--- a/drivers/regulator/pv88090-regulator.c
+++ b/drivers/regulator/pv88090-regulator.c
@@ -43,7 +43,7 @@ enum {
 struct pv88090_regulator {
 	struct regulator_desc desc;
 	/* Current limiting */
-	unsigned	n_current_limits;
+	unsigned int n_current_limits;
 	const int	*current_limits;
 	unsigned int limit_mask;
 	unsigned int conf;
@@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c,
 				return ret;
 
 			range = (range >>
-				 (PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
-				PV88080_BUCK_VRANGE_GAIN_MASK;
+				 (PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
+				PV88090_BUCK_VRANGE_GAIN_MASK;
 			index = ((range << 1) | conf2);
+			if (index > PV88090_ID_BUCK3) {
+				dev_err(chip->dev,
+					"Invalid index(%d)\n", index);
+				return -EINVAL;
+			}
 
 			pv88090_regulator_info[i].desc.min_uV
 				= pv88090_buck_vol[index].min_uV;
diff --git a/drivers/regulator/pv88090-regulator.h b/drivers/regulator/pv88090-regulator.h
index d7aca8d8266d..62d9029277f4 100644
--- a/drivers/regulator/pv88090-regulator.h
+++ b/drivers/regulator/pv88090-regulator.h
@@ -89,10 +89,10 @@
 #define PV88090_BUCK_VDAC_RANGE_2			0x01
 
 /* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */
-#define PV88080_BUCK_VRANGE_GAIN_SHIFT			3
-#define PV88080_BUCK_VRANGE_GAIN_MASK			0x01
+#define PV88090_BUCK_VRANGE_GAIN_SHIFT			3
+#define PV88090_BUCK_VRANGE_GAIN_MASK			0x01
 
-#define PV88080_BUCK_VRANGE_GAIN_1			0x00
-#define PV88080_BUCK_VRANGE_GAIN_2			0x01
+#define PV88090_BUCK_VRANGE_GAIN_1			0x00
+#define PV88090_BUCK_VRANGE_GAIN_2			0x01
 
 #endif	/* __PV88090_REGISTERS_H__ */
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-30 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30  8:54 [PATCH V1] regulator: pv88090: Exception handling for out of bounds Eric Jeong
2017-08-30 15:12 ` Mark Brown
2017-08-30 15:23 ` Applied "regulator: pv88090: Exception handling for out of bounds" to the regulator tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.