All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06  3:30 ` Yizhuo
  0 siblings, 0 replies; 8+ messages in thread
From: Yizhuo @ 2019-02-06  3:30 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Patrice Chotard, Kishon Vijay Abraham I,
	linux-arm-kernel, linux-kernel

In function miphy_osc_is_ready(), local variable "val"
could be uninitalized. if function regmap_read() returns
-EINVAL. However, this value is used in if statement.
This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/st/phy-miphy28lp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
index 213e2e15339c..40c7c0a611a0 100644
--- a/drivers/phy/st/phy-miphy28lp.c
+++ b/drivers/phy/st/phy-miphy28lp.c
@@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 {
 	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
 	unsigned long finish = jiffies + 5 * HZ;
-	u32 val;
+	u32 val = 0;
+	int ret;
 
 	if (!miphy_phy->osc_rdy)
 		return 0;
@@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 		return -EINVAL;
 
 	do {
-		regmap_read(miphy_dev->regmap,
+		ret = regmap_read(miphy_dev->regmap,
 				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
+		if (ret)
+			return ret;
 
 		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
 			cpu_relax();
-- 
2.17.1


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

* [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06  3:30 ` Yizhuo
  0 siblings, 0 replies; 8+ messages in thread
From: Yizhuo @ 2019-02-06  3:30 UTC (permalink / raw)
  Cc: csong, linux-kernel, zhiyunq, Patrice Chotard,
	Kishon Vijay Abraham I, Yizhuo, linux-arm-kernel

In function miphy_osc_is_ready(), local variable "val"
could be uninitalized. if function regmap_read() returns
-EINVAL. However, this value is used in if statement.
This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/st/phy-miphy28lp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
index 213e2e15339c..40c7c0a611a0 100644
--- a/drivers/phy/st/phy-miphy28lp.c
+++ b/drivers/phy/st/phy-miphy28lp.c
@@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 {
 	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
 	unsigned long finish = jiffies + 5 * HZ;
-	u32 val;
+	u32 val = 0;
+	int ret;
 
 	if (!miphy_phy->osc_rdy)
 		return 0;
@@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 		return -EINVAL;
 
 	do {
-		regmap_read(miphy_dev->regmap,
+		ret = regmap_read(miphy_dev->regmap,
 				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
+		if (ret)
+			return ret;
 
 		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
 			cpu_relax();
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
  2019-02-06  3:30 ` Yizhuo
@ 2019-02-06  8:39   ` Patrice CHOTARD
  -1 siblings, 0 replies; 8+ messages in thread
From: Patrice CHOTARD @ 2019-02-06  8:39 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, zhiyunq, Kishon Vijay Abraham I, linux-arm-kernel, linux-kernel

Hi Yizhuo

On 2/6/19 4:30 AM, Yizhuo wrote:
> In function miphy_osc_is_ready(), local variable "val"
> could be uninitalized. if function regmap_read() returns
> -EINVAL. However, this value is used in if statement.
> This is potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/phy/st/phy-miphy28lp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 213e2e15339c..40c7c0a611a0 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  {
>  	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
>  	unsigned long finish = jiffies + 5 * HZ;
> -	u32 val;
> +	u32 val = 0;
> +	int ret;
>  
>  	if (!miphy_phy->osc_rdy)
>  		return 0;
> @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  		return -EINVAL;
>  
>  	do {
> -		regmap_read(miphy_dev->regmap,
> +		ret = regmap_read(miphy_dev->regmap,
>  				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> +		if (ret)
> +			return ret;
>  
>  		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
>  			cpu_relax();
> 

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

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

* Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06  8:39   ` Patrice CHOTARD
  0 siblings, 0 replies; 8+ messages in thread
From: Patrice CHOTARD @ 2019-02-06  8:39 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, zhiyunq, linux-kernel, linux-arm-kernel, Kishon Vijay Abraham I

Hi Yizhuo

On 2/6/19 4:30 AM, Yizhuo wrote:
> In function miphy_osc_is_ready(), local variable "val"
> could be uninitalized. if function regmap_read() returns
> -EINVAL. However, this value is used in if statement.
> This is potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/phy/st/phy-miphy28lp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 213e2e15339c..40c7c0a611a0 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  {
>  	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
>  	unsigned long finish = jiffies + 5 * HZ;
> -	u32 val;
> +	u32 val = 0;
> +	int ret;
>  
>  	if (!miphy_phy->osc_rdy)
>  		return 0;
> @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  		return -EINVAL;
>  
>  	do {
> -		regmap_read(miphy_dev->regmap,
> +		ret = regmap_read(miphy_dev->regmap,
>  				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> +		if (ret)
> +			return ret;
>  
>  		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
>  			cpu_relax();
> 

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
  2019-02-06  3:30 ` Yizhuo
@ 2019-02-06 11:36   ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 8+ messages in thread
From: Kishon Vijay Abraham I @ 2019-02-06 11:36 UTC (permalink / raw)
  To: Yizhuo; +Cc: csong, zhiyunq, Patrice Chotard, linux-arm-kernel, linux-kernel

Hi Yizhuo,

On 06/02/19 9:00 AM, Yizhuo wrote:
> In function miphy_osc_is_ready(), local variable "val"
> could be uninitalized. if function regmap_read() returns
> -EINVAL. However, this value is used in if statement.
> This is potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>

Can you send all your fixes in a series?

Thanks
Kishon
> ---
>  drivers/phy/st/phy-miphy28lp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 213e2e15339c..40c7c0a611a0 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  {
>  	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
>  	unsigned long finish = jiffies + 5 * HZ;
> -	u32 val;
> +	u32 val = 0;
> +	int ret;
>  
>  	if (!miphy_phy->osc_rdy)
>  		return 0;
> @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  		return -EINVAL;
>  
>  	do {
> -		regmap_read(miphy_dev->regmap,
> +		ret = regmap_read(miphy_dev->regmap,
>  				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> +		if (ret)
> +			return ret;
>  
>  		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
>  			cpu_relax();
> 

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

* Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06 11:36   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 8+ messages in thread
From: Kishon Vijay Abraham I @ 2019-02-06 11:36 UTC (permalink / raw)
  To: Yizhuo; +Cc: csong, zhiyunq, Patrice Chotard, linux-arm-kernel, linux-kernel

Hi Yizhuo,

On 06/02/19 9:00 AM, Yizhuo wrote:
> In function miphy_osc_is_ready(), local variable "val"
> could be uninitalized. if function regmap_read() returns
> -EINVAL. However, this value is used in if statement.
> This is potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>

Can you send all your fixes in a series?

Thanks
Kishon
> ---
>  drivers/phy/st/phy-miphy28lp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 213e2e15339c..40c7c0a611a0 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  {
>  	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
>  	unsigned long finish = jiffies + 5 * HZ;
> -	u32 val;
> +	u32 val = 0;
> +	int ret;
>  
>  	if (!miphy_phy->osc_rdy)
>  		return 0;
> @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  		return -EINVAL;
>  
>  	do {
> -		regmap_read(miphy_dev->regmap,
> +		ret = regmap_read(miphy_dev->regmap,
>  				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> +		if (ret)
> +			return ret;
>  
>  		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
>  			cpu_relax();
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06  3:12 ` Yizhuo
  0 siblings, 0 replies; 8+ messages in thread
From: Yizhuo @ 2019-02-06  3:12 UTC (permalink / raw)
  Cc: csong, zhuyunq, Yizhuo, Patrice Chotard, Kishon Vijay Abraham I,
	linux-arm-kernel, linux-kernel

In function miphy_osc_is_ready(), local variable "val"
could be uninitalized. if function regmap_read() returns
-EINVAL. However, this value is used in if statement.
This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/st/phy-miphy28lp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
index 213e2e15339c..40c7c0a611a0 100644
--- a/drivers/phy/st/phy-miphy28lp.c
+++ b/drivers/phy/st/phy-miphy28lp.c
@@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 {
 	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
 	unsigned long finish = jiffies + 5 * HZ;
-	u32 val;
+	u32 val = 0;
+	int ret;
 
 	if (!miphy_phy->osc_rdy)
 		return 0;
@@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 		return -EINVAL;
 
 	do {
-		regmap_read(miphy_dev->regmap,
+		ret = regmap_read(miphy_dev->regmap,
 				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
+		if (ret)
+			return ret;
 
 		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
 			cpu_relax();
-- 
2.17.1


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

* [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
@ 2019-02-06  3:12 ` Yizhuo
  0 siblings, 0 replies; 8+ messages in thread
From: Yizhuo @ 2019-02-06  3:12 UTC (permalink / raw)
  Cc: csong, Yizhuo, linux-kernel, Patrice Chotard,
	Kishon Vijay Abraham I, zhuyunq, linux-arm-kernel

In function miphy_osc_is_ready(), local variable "val"
could be uninitalized. if function regmap_read() returns
-EINVAL. However, this value is used in if statement.
This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/st/phy-miphy28lp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
index 213e2e15339c..40c7c0a611a0 100644
--- a/drivers/phy/st/phy-miphy28lp.c
+++ b/drivers/phy/st/phy-miphy28lp.c
@@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 {
 	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
 	unsigned long finish = jiffies + 5 * HZ;
-	u32 val;
+	u32 val = 0;
+	int ret;
 
 	if (!miphy_phy->osc_rdy)
 		return 0;
@@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
 		return -EINVAL;
 
 	do {
-		regmap_read(miphy_dev->regmap,
+		ret = regmap_read(miphy_dev->regmap,
 				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
+		if (ret)
+			return ret;
 
 		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
 			cpu_relax();
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-06 11:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06  3:30 [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized Yizhuo
2019-02-06  3:30 ` Yizhuo
2019-02-06  8:39 ` Patrice CHOTARD
2019-02-06  8:39   ` Patrice CHOTARD
2019-02-06 11:36 ` Kishon Vijay Abraham I
2019-02-06 11:36   ` Kishon Vijay Abraham I
  -- strict thread matches above, loose matches on Subject: below --
2019-02-06  3:12 Yizhuo
2019-02-06  3:12 ` Yizhuo

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.