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

In function rockchip_usb3_phy_power_on(), local variable
"val" could be uninitialized if function regmap_read()
returns -EINVAL. However, this value is directly used in
later context. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index a958c9bced01..b1e24418cb2d 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 
 	/* wait TCPHY for pipe ready */
 	for (timeout = 0; timeout < 100; timeout++) {
-		regmap_read(tcphy->grf_regs, reg->offset, &val);
+		ret = regmap_read(tcphy->grf_regs, reg->offset, &val);
+		if (ret)
+			goto unlock_ret;
+
 		if (!(val & BIT(reg->enable_bit))) {
 			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
 			goto unlock_ret;
-- 
2.17.1


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

* [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized
@ 2019-02-06  2:18 ` Yizhuo
  0 siblings, 0 replies; 5+ messages in thread
From: Yizhuo @ 2019-02-06  2:18 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Kishon Vijay Abraham I, Heiko Stuebner,
	linux-kernel, linux-arm-kernel, linux-rockchip

In function rockchip_usb3_phy_power_on(), local variable
"val" could be uninitialized if function regmap_read()
returns -EINVAL. However, this value is directly used in
later context. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index a958c9bced01..b1e24418cb2d 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 
 	/* wait TCPHY for pipe ready */
 	for (timeout = 0; timeout < 100; timeout++) {
-		regmap_read(tcphy->grf_regs, reg->offset, &val);
+		ret = regmap_read(tcphy->grf_regs, reg->offset, &val);
+		if (ret)
+			goto unlock_ret;
+
 		if (!(val & BIT(reg->enable_bit))) {
 			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
 			goto unlock_ret;
-- 
2.17.1

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

* [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized
@ 2019-02-06  2:18 ` Yizhuo
  0 siblings, 0 replies; 5+ messages in thread
From: Yizhuo @ 2019-02-06  2:18 UTC (permalink / raw)
  Cc: csong, Heiko Stuebner, zhiyunq, linux-kernel,
	Kishon Vijay Abraham I, Yizhuo, linux-rockchip, linux-arm-kernel

In function rockchip_usb3_phy_power_on(), local variable
"val" could be uninitialized if function regmap_read()
returns -EINVAL. However, this value is directly used in
later context. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index a958c9bced01..b1e24418cb2d 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 
 	/* wait TCPHY for pipe ready */
 	for (timeout = 0; timeout < 100; timeout++) {
-		regmap_read(tcphy->grf_regs, reg->offset, &val);
+		ret = regmap_read(tcphy->grf_regs, reg->offset, &val);
+		if (ret)
+			goto unlock_ret;
+
 		if (!(val & BIT(reg->enable_bit))) {
 			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
 			goto unlock_ret;
-- 
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] 5+ messages in thread

* Re: [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized
  2019-02-06  2:18 ` Yizhuo
@ 2019-02-12 10:49   ` Heiko Stübner
  -1 siblings, 0 replies; 5+ messages in thread
From: Heiko Stübner @ 2019-02-12 10:49 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, zhiyunq, Kishon Vijay Abraham I, linux-kernel,
	linux-arm-kernel, linux-rockchip

Am Mittwoch, 6. Februar 2019, 03:18:10 CET schrieb Yizhuo:
> In function rockchip_usb3_phy_power_on(), local variable
> "val" could be uninitialized if function regmap_read()
> returns -EINVAL. However, this value is directly used in
> later context. This is potentially unsafe.

While highly unlikely case (GRF-registers are mmio-based),
it's still nicer to go the clean way, so

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c
> b/drivers/phy/rockchip/phy-rockchip-typec.c index
> a958c9bced01..b1e24418cb2d 100644
> --- a/drivers/phy/rockchip/phy-rockchip-typec.c
> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c
> @@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
> 
>  	/* wait TCPHY for pipe ready */
>  	for (timeout = 0; timeout < 100; timeout++) {
> -		regmap_read(tcphy->grf_regs, reg->offset, &val);
> +		ret = regmap_read(tcphy->grf_regs, reg->offset, &val);
> +		if (ret)
> +			goto unlock_ret;
> +
>  		if (!(val & BIT(reg->enable_bit))) {
>  			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
>  			goto unlock_ret;





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

* Re: [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized
@ 2019-02-12 10:49   ` Heiko Stübner
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Stübner @ 2019-02-12 10:49 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, zhiyunq, linux-kernel, Kishon Vijay Abraham I,
	linux-rockchip, linux-arm-kernel

Am Mittwoch, 6. Februar 2019, 03:18:10 CET schrieb Yizhuo:
> In function rockchip_usb3_phy_power_on(), local variable
> "val" could be uninitialized if function regmap_read()
> returns -EINVAL. However, this value is directly used in
> later context. This is potentially unsafe.

While highly unlikely case (GRF-registers are mmio-based),
it's still nicer to go the clean way, so

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c
> b/drivers/phy/rockchip/phy-rockchip-typec.c index
> a958c9bced01..b1e24418cb2d 100644
> --- a/drivers/phy/rockchip/phy-rockchip-typec.c
> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c
> @@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
> 
>  	/* wait TCPHY for pipe ready */
>  	for (timeout = 0; timeout < 100; timeout++) {
> -		regmap_read(tcphy->grf_regs, reg->offset, &val);
> +		ret = regmap_read(tcphy->grf_regs, reg->offset, &val);
> +		if (ret)
> +			goto unlock_ret;
> +
>  		if (!(val & BIT(reg->enable_bit))) {
>  			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
>  			goto unlock_ret;





_______________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2019-02-12 10:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06  2:18 [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized Yizhuo
2019-02-06  2:18 ` Yizhuo
2019-02-06  2:18 ` Yizhuo
2019-02-12 10:49 ` Heiko Stübner
2019-02-12 10:49   ` Heiko Stübner

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.